php 7 bug in substr_replace function
| From: | Pascal KISSIAN | Date: | Tue, 15 Mar 2016 12:51:07 +0000 |
| Subject: | php 7 bug in substr_replace function | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-91665@lists.php.net to get a copy of this message | ||
Hi everybody,
I don't know if this is the right place to report bugs. please let me know
for the next time.
This is a small snippet that shows the wrong behaviour :
<?php
$line = str_repeat(' ',20); $value ='03'; $pos=0; $len='2';
$line = substr_replace($line,$value,$pos,$len);
echo "[$line]\n";
?>
When running it under php 7, $line is unchanged and a message is emitted :
PHP Warning: substr_replace(): 'from' and 'len' should be of same type -
numerical or array in test.php on line 3.
$len is not auto-casted in integer.. Btw the message is not very clear as
it mentions from and len that are not within the doc.
(in my real source code, $len was extracted as string from a database).
When $len is an integer, the function works as expected.
Tested ok on php 5.3.10
Tested Not ok on php 7.0.3
Best regards,
Pascal KISSIAN