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!

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

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?