祝大家日安。我使用的是zend+smarty,但我不认为框架与这个问题有任何关系。我有以下场景:
A script that gets a string from a specified site using an api. The string is retrieved corectly so I'll just assign a string to a variable:
$string = 'String retrieved from api.';
$string = strstr($string, "<?xml", false);
libxml_use_internal_errors(true);
$xml = simplexml_load_string($body);听起来不错,看起来不错。现在问题来了。
当我在我们的本地测试机器上使用它时,它就像做梦一样工作。一点问题都没有。另一方面,在生产机器上,我得到这样的结果:
警告:第720行/home/prj/include/DatabaseObject/Ctrl.php中strstr()的参数计数错误(这是strstr行)。
我在两台机器上的strstr之前检查了字符串,它们是相同的。同样,在第二台服务器上,在strstr行之后,字符串变为空(在另一台服务器上,它被正确转换)。
我真的不明白。代码是相同的。字符串是相同的。对我来说有点奇怪。
发布于 2011-04-29 23:52:44
第三个参数“在针之前”-一个布尔值-是在php 5.3中添加的。您的生产服务器很可能运行的是早期版本。
请参阅PHP.net
strstr ( string $haystack , mixed $needle [, bool $before_needle = false ] )
添加了可选参数before_needle.的
https://stackoverflow.com/questions/5834254
复制相似问题