#41395 [Bgs]: behaviour of substr_replace changed in php 5.2.2
| From: | daniel dot menard at bdsp dot tm dot fr | Date: | Mon, 21 May 2007 07:16:58 +0000 |
| Subject: | #41395 [Bgs]: behaviour of substr_replace changed in php 5.2.2 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-112888@lists.php.net to get a copy of this message | ||
ID: 41395
User updated by: daniel dot menard at bdsp dot tm dot fr
Reported By: daniel dot menard at bdsp dot tm dot fr
Status: Bogus
Bug Type: Strings related
Operating System: windows 2003 server
PHP Version: 5.2.2
New Comment:
I double-checked the manual :
"If length is given and is positive, it represents the length of the
portion of string which is to be replaced. If it is negative, it
represents the number of characters from the end of string at which to
stop replacing. If it is not given, then it will default to strlen(
string ); i.e. end the replacing at the end of string. Of course, if
length is zero then this function will have the effect of inserting
replacement into string at the given start offset."
I see nothing saying what happens if length is greater than the length
of the string, neither I see anything stating that there were changes
concerning this function in php 5.2.2...
Previous Comments:
------------------------------------------------------------------------
[2007-05-16 12:58:17] tony2001@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
------------------------------------------------------------------------
[2007-05-15 08:53:02] daniel dot menard at bdsp dot tm dot fr
Description:
------------
The behaviour of substr_replace seems to have changed in php 5.2.2 when
the length parameter is specified and is greater than the actual length
of the string to modify.
With php < 5.2.2, the string is extended, with php 5.2.2 substr_replace
returns false.
I don't know if this is an intended change or not, but this change is
not documented in the function description.
Just in case it matters: I'm using php 5.2.2 in cli mode with
apache/2.2.4 on a windows 2003 server.
Note: perhaps it is related to http://bugs.php.net/bug.php?id=40754
Thanks !
Reproduce code:
---------------
<?php
echo PHP_VERSION, ' : ';
var_dump(substr_replace('012', 'ABCD', 0, 4));
?>
Expected result:
----------------
either the same result as in in previous php versions
or a note in the documentation stating that the behaviour has changed.
Actual result:
--------------
with PHP 5.2.2, I get:
5.2.2 : bool(false)
With older versions of php I get:
5.2.1 : string(4) "ABCD"
5.2.0 : string(4) "ABCD"
5.1.2 : string(4) "ABCD"
5.1.1 : string(4) "ABCD"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41395&edit=1