可能重复:
PHP session side-effect warning with global variables as a source of data
我收到来自php
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
我相信以下代码会产生警告。
$name=$_SESSION['name'];
$emails=$_SESSION['email'];
$_SESSION['info']=array_intersect($name, $emails);
我无法访问php.ini
或服务器。我只能改变我的代码。
反正有没有删除警告?
答案 0 :(得分:3)
这意味着您有一个与会话变量同名的变量如下所示。
$_SESSION['variable'] = null;
$variable = 'data';
您可以通过在php.ini或.htaccess中将这些行添加到脚本中来阻止PHP尝试查找现有变量并向您发出警告
ini_set('session.bug_compat_warn', 0);
ini_set('session.bug_compat_42', 0);
答案 1 :(得分:2)
这将删除错误:
ini_set('session.bug_compat_42',0);
ini_set('session.bug_compat_warn',0);
您也可以从.htaccess文件中删除它,或者如果可用的话,还可以在目录的根目录中关闭它。