php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #42710 Strspn() documentation needs more explanation for start and length arguments
Submitted: 2007-09-19 12:36 UTC Modified: 2007-11-21 15:59 UTC
From: nikhil dot gupta at in dot ibm dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: Linux, Win32-xp
Private report: No CVE-ID: None
 [2007-09-19 12:36 UTC] nikhil dot gupta at in dot ibm dot com
Description:
------------
The documentation for strspn() seems to be incomplete. It donot explains the function behaviour with negative values of start and len argument.Without looking at the PHP source code one cannot confirm the behaviour of the function for negative start and len values.



Reproduce code:
---------------
Following can be added to the documentation:

1. When fourth argument(len) is not passed
   a)if $start<0 and $start >= -(length of $str) then
     start=start+length of $str
   b)if $start<0 and start < -(length of $str A)
   c)By default, $len=length of $str

2. When all four arguments are passed to the function:
   a)if $start<0 and $start >= -(length of $str) then
     start=start+length of $str
   b)if $start<0 and start < -(length of $str A)
   c)if $len<0 and $len >= -(length of $str - $start) then
     len=len+(length of $str - $start)
   d)if $len<0 and $len < -(length of $str - $start) then
     len=0.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-21 15:59 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.

"Negative value counts position from the end of a string.
Negative value sets length from the end of a string."
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 11:00:02 2026 UTC