php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #52509 strcspn() docs are not clear
Submitted: 2010-08-01 21:14 UTC Modified: 2010-08-10 19:38 UTC
From: mr dot joebert at gmail dot com Assigned: philip (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mr dot joebert at gmail dot com
New email:
PHP Version: OS:

 

 [2010-08-01 21:14 UTC] mr dot joebert at gmail dot com
Description:
------------
The description for the strcspn function is confusing.

"Returns the length of the initial segment of str1 which does not contain any of the characters in str2."

This seems to indicate that the function looks for a string of unexpected characters and returns the length of that string. When what really happens, is that the function will either return zero, or, if the string starts with unexpected characters, return the length of that.

Behavior I would expect from the description,

strcspn('abcd', 'abc') == 1
strcspn('dabc', 'abc') == 1

What really happens

strcspn('abcd', 'abc') == 0
strcspn('dabc', 'abc') == 1


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-08-10 19:29 UTC] philip@php.net
-Summary: Confusing description +Summary: strcspn() docs are not clear -Status: Open +Status: Assigned -Assigned To: +Assigned To: philip
 [2010-08-10 19:37 UTC] philip@php.net
Automatic comment from SVN on behalf of philip
Revision: http://svn.php.net/viewvc/?view=revision&revision=302077
Log: Added example to clarify behavior. Closes PHP bug #52509
 [2010-08-10 19:38 UTC] philip@php.net
-Status: Assigned +Status: Closed
 [2010-08-10 19:38 UTC] philip@php.net
This is fixed in SVN (and will show up online this upcoming Friday), thanks for 
the bug report :)
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sat Oct 10 10:00:02 2026 UTC