php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #60949 The documentation about the return value is not clear!
Submitted: 2012-02-01 14:54 UTC Modified: 2012-02-04 20:41 UTC
From: waldemar dot renke at kirchner-solar-group dot de Assigned: frozenfire (profile)
Status: Closed Package: *General Issues
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2012-02-01 14:54 UTC] waldemar dot renke at kirchner-solar-group dot de
Description:
------------
---
From manual page: http://www.php.net/function.substr#refsect1-function.substr-returnvalues
---

"Returns the extracted part of string, or FALSE on failure or an empty string."

Question: Does it return and empty string on failure, or when it doesn't find a string???


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-02-01 16:39 UTC] anon at anon dot anon
What it means is that unlike most languages, PHP's substr stupidly returns boolean false instead of "" for cases like substr("abcde", 5). (And just to be extra unhelpful, it returns null if it doesn't like its parameters.)
 [2012-02-04 17:20 UTC] php-dev at zerocue dot com
At least it is well document. 

Waldemar: It depends on your inputs, see the information on start and length 
parameters and it explains what it does in what cases.
 [2012-02-04 20:41 UTC] frozenfire@php.net
Automatic comment from SVN on behalf of frozenfire
Revision: http://svn.php.net/viewvc/?view=revision&revision=323058
Log: Clarified empty string return value. Closes bug #60949.
 [2012-02-04 20:41 UTC] frozenfire@php.net
This bug has been fixed in SVN.

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.


 [2012-02-04 20:41 UTC] frozenfire@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: frozenfire
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 23:01:30 2024 UTC