php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #26916 docs for substr("", 0, 0) is not clear
Submitted: 2004-01-15 06:16 UTC Modified: 2004-01-15 10:01 UTC
From: csongibacsi at nexum dot hu Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 4.3.4 OS: Linux video 2.4.18-bf2.4 #1 Son
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: csongibacsi at nexum dot hu
New email:
PHP Version: OS:

 

 [2004-01-15 06:16 UTC] csongibacsi at nexum dot hu
Description:
------------
The real behaviour is different from the one which is described in the docs. 

The docs says: "If string is less than start characters long, FALSE will be returned." In the case of the parameters described below, the string "abc" is not less than 3 characters long so it should NOT give back FALSE, but it gives. 

Reproduce code:
---------------
  var_dump( substr( "abc", 3, 0 ) );


Expected result:
----------------
  string(0) "" 



Actual result:
--------------
  bool(false)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-15 06:57 UTC] eru@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

Ehm the string \"abc\" has no [3], we start counting at 0.

\"If start is non-negative, the returned string will start at the start\'th position in string, counting from zero.\"

 [2004-01-15 10:01 UTC] csongibacsi at nexum dot hu
Well, it's OK, the characters are counted from 0, but the sentence below is not true:
"If string is less than start characters long, FALSE will
be returned."
The true version should be:
"False is returned if string is less OR EQUAL than start characters long." Shouldn't it?
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon May 16 16:05:46 2022 UTC