Re: substr passing null...
| From: | Peter Walther | Date: | Wed, 28 Jan 2009 15:54:06 +0000 |
| Subject: | Re: substr passing null... | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-42867@lists.php.net to get a copy of this message | ||
On 27.01.2009 17:36, Nathanael D. Noblet wrote:
Johannes Schlüter wrote:it's only a bug if you always expect optional NULL parameters to be ignored. substr() expects an int as the 3rd parameter (int) null => 0 substr($string, $start, null) => substr($string, $start, 0) = > "" (empty_string) HTHSo this morning I downloaded php5.2-200901271530, php5.3-200901271530, compiled with ./configure --prefix=/home/gnat/php5.{2,3} respectively and then used the following source file to see how they behaved. test.php: <?php $string = 'The String is here'; echo "STRING: $string\n"; echo "SUB".substr($string,3,null)."\n"; echo "END\n"; ?> in both cases the output I get is STRING: The String is here SUB END showing that passing null as the third param for substr is somehow interpreted to mean no length or something. Is this indeed a bug then? and if so where can I submit it?I know Ilia recently fixed a few functions that didn't ignore null parameters, but it doesn't appear that substr() was one of them.I guess that's part of the zend_parse_parameters changes. As we now use the "s" modifier for instance which might better be a "s!". We should certainly spent some time on checking these things. All remember: We're feature freezing, so spend time on finding and fixing bugs instead of adding new ones! :-) (this includes users who can at least report such issues ... )