使用全局变量作为数据源的 PHP 会话副作用警告 [英] PHP session side-effect warning with global variables as a source of data

查看:12
本文介绍了使用全局变量作为数据源的 PHP 会话副作用警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试托管一个给我的 PHP 网站.我看到这个警告:

I'm trying to host a PHP web site that was given to me. I see this warning:

警告:未知:您的脚本可能依赖于会话副作用一直存在到 PHP 4.2.3.请成为建议会话扩展不考虑全局变量数据来源,除非register_globals 已启用.你可以禁用这个功能和这个通过设置警告session.bug_compat_42 或session.bug_compat_warn 关闭,分别.在未知0

Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0

这是什么意思?我如何在代码中追踪这个问题的根源?

What does this mean? How might I track down the source of this problem within the code?

推荐答案

基本上,您有一个与会话同名的变量.例如:

basically you have a variable with the same name as your session. ex:

$_SESSION['var1'] = null;
$var1 = 'something';

这将重现此错误.您可以通过将这些行添加到您的脚本中来阻止 PHP 尝试查找现有变量并警告您:

which will reproduce this error. you can stop PHP from trying to find existing variables and warning you about them by adding these lines to your script:

ini_set('session.bug_compat_warn', 0);
ini_set('session.bug_compat_42', 0);

这些值也可以在 php.ini 或 .htaccess 中设置

these values can be set in php.ini or .htaccess as well

这篇关于使用全局变量作为数据源的 PHP 会话副作用警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆