Doc #53056 [Wfx->Bgs]: Incomplete information for return value of preg_match
| From: | salathe@php.net | Date: | Thu, 14 Oct 2010 09:18:00 +0000 |
| Subject: | Doc #53056 [Wfx->Bgs]: Incomplete information for return value of preg_match | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-5215@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=53056&edit=1
ID: 53056
Updated by: salathe@php.net
Reported by: daniel at parthenonsoftware dot com
Summary: Incomplete information for return value of
preg_match
-Status: Wont fix
+Status: Bogus
Type: Documentation Problem
Package: Documentation problem
Operating System: All
PHP Version: 5.3.3
Block user comment: N
New Comment:
The documentation already clearly states (under the heading "Return
Values"):
preg_match() returns the number of times pattern matches.
That will be either 0 times (no match) or 1 time because
preg_match() will stop searching after the first match.
The above essentially paraphrases your own suggested addition.
Previous Comments:
------------------------------------------------------------------------
[2010-10-14 10:55:25] daniel at parthenonsoftware dot com
Then I would like to invite you to speak english
------------------------------------------------------------------------
[2010-10-14 04:49:37] aharvey@php.net
The preg_match() return values section already seems completely clear to
me.
------------------------------------------------------------------------
[2010-10-14 00:05:45] daniel at parthenonsoftware dot com
Description:
------------
While the documentation accurately tells the programmer that preg_match
returns an int, the documentation does not reflect the meaning of the
return value.
As an example, in shell scripting, 0 represents true, where another
number typically represents an error code. Returning 0 from a main
application means everything went successfully.
Further, in some languages like C/C++, 0 is the default return value,
basically meaning "Everything fine nothing to see here move along
please". ;-)
The confusion comes from the fact that the preg_match() function returns
1 if a match is found and 0 otherwise.
By adding this sentence to the documentation for preg_match:
The preg_match() function returns 1 if a match is found and 0
otherwise.
A fair bit of confusion would be cleared up by defining the non-standard
meaning up front.
Actual result:
--------------
tt
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53056&edit=1