-1

I am getting a Fatal Error for a function that is cleared defined AND working correctly. Even though it does its job it still says that it is "undefined." Has anyone experienced that before?

/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(); ?>

All the other stuff shouldn't have a factor.

the error states on the index.php that

Fatal error: Call to undefined function is_logged_in() in C:\xampp\htdocs\ionz\2.0\includes\adminbar.php on line 1

Nicholas P.
  • 353
  • 4
  • 14

1 Answers1

0

You'll see this if both functions are in the same class, in which case you need to write:

if ($this->is_logged_in())

Or you could be missing a brace somewhere, which would make your function a nested function. Take a look at this issue too: PHP Call to undefined function

Rob Johnston
  • 859
  • 8
  • 21