关于$ _GET的PHP 5.4特定的ISSET查询。 $ _POST Superglobals
I have to upgrade a mission-critical (aren't they all?) Ubuntu server from PHP 5.3 to 5.4, and am happy about all but 1 possible problem. Our PHP scripts include around 1200 ISSET() references, nearly all of which check the status of either $_GET or $_POST variables, whose names all comprise strings, not numerics.
I'm aware of the (5.3 v 5.4) distinction where 5.4 returns false when ISSET($var['somestringvalue']) is used, and my query is whether this unwanted behaviour will apply to our string-value $_POST and $_GET variables?
I would knock up a quick 5.4 test server, but we use so many extensions and adjustments that even that's easier said than done. so I thought I'd try my luck here first. Thanks in advance.
我必须从PHP 5.3到5.4升级任务关键(不是全部吗?)Ubuntu服务器, 除了1个可能的问题之外,我很高兴。 我们的PHP脚本包含大约1200个ISSET()引用,几乎所有这些引用都检查$ _GET或$ _POST变量的状态,这些变量的名称都包含字符串,而不是数字。 p >
我知道(5.3 v 5.4)区别,当使用ISSET($ var [' somestringvalue em>'])时5.4返回false,我的查询是否 这个不受欢迎的行为将适用于我们的字符串值$ _POST和$ _GET变量? p>
我会敲一个快速的5.4测试服务器,但是我们使用了很多扩展和调整,即使这样也更容易 说完了。 所以我想我先试试运气。 提前致谢。 p>
div>
That is not an "unwanted behaviour", it's actually useful. The behaviour only changes if isset() is called on a string.
$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)
Since $_GET and $_POST are always associative arrays, this new behaviour will not affect you in any case. For more information, check the manual at http://php.net/manual/en/function.isset.php
PS: you should consider a development server, to test things like this without creating problems for your users / customers!