我必须升级一个关键任务(不是全部吗?)Ubuntu服务器从PHP 5.3到5.4,我很高兴除了1个可能的问题。 我们的PHP脚本包含大约1200个ISSET()引用,几乎所有引用都检查$ _GET或$ _POST变量的状态,这些变量的名称都包含字符串,而不是数字。
我知道(5.3 v 5.4)的区别,当使用ISSET($ var [' somestringvalue '])时5.4返回false,我的查询是这个不需要的行为是否适用到我们的字符串值$ _POST和$ _GET变量?
我会敲一个快速的5.4测试服务器,但是我们使用了很多扩展和调整,即使说起来容易做起来难。所以我想我先试试运气。提前谢谢。
答案 0 :(得分:1)
这不是“不受欢迎的行为”,它实际上很有用。只有在字符串上调用isset()时,行为才会更改。
$string = 'My string'; // length = 9, character indexes 0 to 8
var_dump(isset($string[5])); // makes sense -> checks whether there's a character on the 5th position (true)
var_dump(isset($string[10])); // makes sense -> checks whether there's a character on the 10th position (false)
var_dump(isset($string['foo'])); // doesn't make sense -> checks whether there's a character on the "foo" position (false)
由于$ _GET和$ _POST始终是关联数组,因此这种新行为在任何情况下都不会对您产生影响。有关详细信息,请查看http://php.net/manual/en/function.isset.php
上的手册PS:您应该考虑使用开发服务器来测试这样的事情而不会给您的用户/客户带来问题!