【发布时间】:2011-12-16 20:06:41
【问题描述】:
我一直在为这段代码发疯,并将其缩小到未设置的功能。当我在会话变量上调用 unset 时,PHP 不会执行任何超出该点的操作。有人可以帮忙吗?
public static function print_session_notification() {
if( isset( $_SESSION['notification'] )) {
$session_notification = $_SESSION['notification'];
$output = '<div class="error">';
$output .= $_SESSION['notification'];
$output .= '</div>';
unset( $_SESSION['notification'] );
return $output;
}
}
我调用打印通知::print_session_notification();从标题包含。标头包含由函数调用。 $notification 对象在调用头文件的函数中是全局的。
【问题讨论】:
-
您发布的代码没有问题,也不会重现您的错误。尝试用尽可能少的代码重现您的错误。对于您发布的内容,我们无法为您提供帮助。
-
您的 register_globals 是否处于“开启”状态? php.net/manual/en/function.unset.php#40539 可能相关:stackoverflow.com/questions/1025300/…
-
我们至少需要查看调用
print_session_notification()的代码或函数。 -
为什么将会话值本地化为 $session_notification,但不使用它?好像你可以摆脱那条线。
-
对不起,伙计们,我忘了提到我调用了 print notification::print_session_notification();从标题包含。头文件包含由函数调用。