我正在使用一个名为Program-E的PHP-AIML程序,之前运行得很好,我知道它应该很稳定,因为它已经完成了一段时间了,但它是为PHP 4.0.4设计的,现在我使用的是PHP 5.0,所以我不知道该怎么办。
我的foreach()函数的代码如下:
// Turn this off in case people have it on.set_magic_quotes_runtime(0);// Can't turn off magic quotes gpc so just redo what it did if it is on.if (get_magic_quotes_gpc()) { foreach($HTTP_GET_VARS as $k=>$v) $HTTP_GET_VARS[$k] = stripslashes($v); foreach($HTTP_POST_VARS as $k=>$v) $HTTP_POST_VARS[$k] = stripslashes($v); foreach($HTTP_COOKIE_VARS as $k=>$v) $HTTP_COOKIE_VARS[$k] = stripslashes($v);}
页面上显示的错误如下:
Warning: Invalid argument supplied for foreach() in /home/content/80/8657080/html/e/src/admin/dbprefs.php on line 42Warning: Invalid argument supplied for foreach() in /home/content/80/8657080/html/e/src/admin/dbprefs.php on line 44Warning: Invalid argument supplied for foreach() in /home/content/80/8657080/html/e/src/admin/dbprefs.php on line 46
那么,我该如何解决这个问题呢?
回答:
根据PHP手册中关于预定义变量文档的条目:
从PHP 5.0.0开始,可以通过register_long_arrays指令禁用长PHP预定义变量数组。
这意味着(已废弃的)$HTTP_GET_VARS
、$HTTP_POST_VARS
和$HTTP_COOKIE_VARS
可能已通过register_long_arrays指令关闭。
你不应该使用这些变量,因为它们已经被废弃了很长时间。相反,应该使用$_GET
、$_POST
和$_COOKIE
超全局变量。
最后,虽然这可能有点令人沮丧,但我个人建议尽可能避免使用为PHP 5.3之前版本优化的任何东西。