Bug #71827 [Opn->Csd]: substr_replace bug when length type is string
| From: | krakjoe@php.net | Date: | Thu, 31 Mar 2016 16:12:11 +0000 |
| Subject: | Bug #71827 [Opn->Csd]: substr_replace bug when length type is string | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-200271@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71827&edit=1
ID: 71827
Updated by: krakjoe@php.net
Reported by: php-mailing-list at lool dot fr
Summary: substr_replace bug when length type is string
-Status: Open
+Status: Closed
Type: Bug
Package: Strings related
PHP Version: 7.0.4
-Assigned To:
+Assigned To: krakjoe
Block user comment: N
Private report: N
New Comment:
The fix for this bug has been committed.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
For Windows:
http://windows.php.net/snapshots/
Thank you for the report, and for helping us make PHP better.
I accidentally tagged the wrong bug number in the commit ...
Previous Comments:
------------------------------------------------------------------------
[2016-03-15 14:50:32] php-mailing-list at lool dot fr
Description:
------------
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
Test script:
---------------
test results on https://3v4l.org/svDrE
<?php
$line = str_repeat(' ',20); $value ='03'; $pos=0; $len='2';
$line = substr_replace($line,$value,$pos,$len);
echo "[$line]\n";
?>
Expected result:
----------------
[03 ]
Actual result:
--------------
Warning: substr_replace(): 'from' and 'len' should be of same type - numerical
or array in /in/svDrE on line 3
[ ]
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71827&edit=1