开发者

PHP - strstr function problem

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.


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 ] )

  • 5.3.0 Added the optional parameter before_needle.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜