I have a function which displays current admin log in information which also displays feedback messages contained in a session variable.
I had it setup so the session variable would be set to null straight after it was displayed. However in the implementation I have the function displaying the variable displays it like so:
function loginInfo()
{
$code .= 'You are logged in as bob.';
$code .= 'msg:'.$_SESSION['msg'];
$_SESSION['msg'] = null;
return $code;
}
function breadCrumbs($section = '')
{
$html .= $this->loginInfo();
$html .= '<h1><a href="/admin">Dashboard</a> > '.$section.'</h1>';
return $html;
}
function dashboard()
{
$html .= $this->breadCrumbs('');
$html .= '<ul>';
$html .= etc..
}
-----------
$_SESSIO开发者_如何学CN['msg'] = 'message here';
header(Redirect "/admin");
exit();
then the dashboard function is called on the new page.
echo $admin->dashboard();
The above always returns null, I'm assuming its because its changed to null in the function before the $code is displayed from the return?
How can I get around this?
No, your code is pretty fine.
You must search in another places.
Search for 2 occurences of loginInfo();
in your code and you'll get it
精彩评论