On 27.01.2009 17:36, Nathanael D. Noblet wrote:
Johannes Schlüter wrote:
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 ... )
So 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?
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)
HTH
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php