donglanfu5831 2014-08-18 16:49
浏览 30
已采纳

关于$ _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.

  • 写回答

1条回答 默认 最新

  • douyan8772 2014-08-18 17:20
    关注

    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!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 pb数据库修改或者求完整pb库存系统,需为pb自带数据库
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路