-1

对于已清除定义并正常工作的功能,我收到了致命错误。即使它完成了它的工作,它仍然说它是“未定义的”。以前有人经历过吗?

/include/adminbar.php

<?php if (is_logged_in()) : ?>
    <div id="globaluserbar" class="gobaluseradminbar" style="position:fixed; top:0px; left:0px; background:#292929; height:42px; width:100%; color:white; vertical-align:middle;">This is the adminbar</div>
<?php endif; ?>

/include/functions.php

function is_logged_in(){
        if (!empty($_SESSION[SESSION_IS_LOGGEDIN]) && $_SESSION[SESSION_IS_LOGGEDIN] == 1) {
            return true;
        } 
    }

function theme_header(){
    include URLBASE."/includes/theme-inc/head.php";
    include URLBASE."/content/themes/default/header.php";
}

function theme_footer(){
    include URLBASE."/content/themes/default/footer.php"; 
    include URLBASE."/includes/adminbar.php";
    include URLBASE."/includes/theme-inc/foot.php";
}

/index.php

<?php theme_header(); ?>
<p>This is the main index!</p>
<?php theme_footer(); ?>

所有其他的东西不应该有一个因素。

index.php 上的错误指出

致命错误:在第 1 行的 C:\xampp\htdocs\ionz\2.0\includes\adminbar.php 中调用未定义函数 is_logged_in()

4

1 回答 1

0

如果两个函数在同一个类中,您会看到这一点,在这种情况下,您需要编写:

if ($this->is_logged_in())

或者您可能在某处缺少大括号,这会使您的函数成为嵌套函数。也看看这个问题: PHP Call to undefined function

于 2015-06-09T23:26:56.900 回答