php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #53935 Wrong Return Value for substr()
Submitted: 2011-02-05 22:38 UTC Modified: 2011-02-10 16:32 UTC
From: miqrogroove at gmail dot com Assigned: vrana (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.2.17 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: miqrogroove at gmail dot com
New email:
PHP Version: OS:

 

 [2011-02-05 22:38 UTC] miqrogroove at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.substr#Changelog
---

According to the "Changelog" this function should return FALSE for substr('abc', -
7) in 5.2.2+.  The actual return value is 'abc' in version 5.2.16.  Did not test 
5.2.17, but the manual is obviously wrong.

Test script:
---------------
echo substr('abc', -7);

Expected result:
----------------
No output.

Actual result:
--------------
abc

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-10 12:35 UTC] vrana@php.net
Automatic comment from SVN on behalf of vrana
Revision: http://svn.php.net/viewvc/?view=revision&revision=308179
Log: Changelog (doc bug #53935)
 [2011-02-10 12:36 UTC] vrana@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: vrana
 [2011-02-10 12:36 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

5.2.2 - 5.2.6: ... Other versions get the string from start.
 [2011-02-10 13:11 UTC] salathe@php.net
-Status: Closed +Status: Re-Opened
 [2011-02-10 13:11 UTC] salathe@php.net
The changelog used to refer to the behaviour in cases such as substr('abc',2,-2).  
As detailed in the changelog before today's amendment, prior to 5.2.2 that case 
returns an empty string and otherwise returns false.

The change in behaviour for the substr('abc',-7) case should be detailed 
separately.
 [2011-02-10 16:32 UTC] vrana@php.net
-Status: Re-Opened +Status: Closed
 [2011-02-10 16:32 UTC] vrana@php.net
Old changelog was wrong. substr("abc", -7) returns "abc" in PHP 5.1.6.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 03:00:02 2026 UTC