#48269 [Opn->Bgs]: Unexpected return in substr function with negative start parameter
| From: | jani@php.net | Date: | Wed, 13 May 2009 21:32:58 +0000 |
| Subject: | #48269 [Opn->Bgs]: Unexpected return in substr function with negative start parameter | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-137270@lists.php.net to get a copy of this message | ||
ID: 48269
Updated by: jani@php.net
Reported By: relo dot san at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: CentOS 5
PHP Version: 5.2.9
New Comment:
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same.
Thank you for your interest in PHP.
See bug #47298
Previous Comments:
------------------------------------------------------------------------
[2009-05-13 20:47:23] relo dot san at gmail dot com
Description:
------------
From manual:
"If length is given and is positive, the string returned will contain
at most length characters beginning from start (depending on the length
of string). If string is less than or equal to start characters long,
FALSE will be returned."
This bug detected in PHP versions >= 5.2.8
Results on different versions and OS:
PHP Version 5.2.5, Windows and linux: boolean: false
PHP Version 5.2.8, CentOS: string(1) "1"
PHP 5.2.8 (cli) (built: Feb 5 2009 21:21:13), MacOS: string(1) "1"
PHP Version 5.2.9, CentOS: string(1) "1"
Maby is mistake in manual and substr do not accept negative start param
if string length less than start?
Reproduce code:
---------------
var_dump( substr( '1', -2, 1 ) );
Expected result:
----------------
boolean: false
Actual result:
--------------
string(1) "1"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=48269&edit=1