PHP-strstr函数问题
祝大家美好的一天。我正在使用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 行之后的第二台服务器上,字符串变为空(在另一台服务器上,它被正确转换)。
我真的不明白......代码是一样的。字符串是一样的。对我来说有点奇怪。
Good day to all. I am using zend+smarty, but I don't think the framework has any thing to do with the problem. I have the following scenario:
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);
Sounds ok, looks ok. Now the problem.
When I use that on our local test machine it works like a dream. No problem at all. On the other hand, on the production machine I get this:
Warning: Wrong parameter count for strstr() in /home/prj/include/DatabaseObject/Ctrl.php on line 720 (this is the strstr line).
I checked the strings before strstr on the 2 machines and they are identical. Also on the second server after the strstr line the string becomes empty (on the other one it is correctly transformed).
I really don't get it... the code is the same. The string is the same. Is a bit strange to me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
第三个参数“before Needle”——一个布尔值——是在 php 5.3 中添加的。您的生产服务器可能正在运行早期版本。
请参阅 PHP.net
strstr ( string $haystack , mix $needle [, bool $before_needle = false ] )
The third paramater "before needle" - a boolean value - was added in php 5.3. It's likely your production server is running an earlier version.
see PHP.net
strstr ( string $haystack , mixed $needle [, bool $before_needle = false ] )