#50983 [Ver->Csd]: default value for $length parameter of substr_compare() is incorrect in docs
| From: | rquadling@php.net | Date: | Thu, 11 Feb 2010 11:18:35 +0000 |
| Subject: | #50983 [Ver->Csd]: default value for $length parameter of substr_compare() is incorrect in docs | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-3870@lists.php.net to get a copy of this message | ||
ID: 50983
Updated by: rquadling@php.net
Reported By: guy dot paddock at gmail dot com
-Status: Verified
+Status: Closed
Bug Type: Documentation problem
Operating System: Debian Etch
PHP Version: 5.2.12
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2010-02-10 10:58:24] rquadling@php.net
According to the source code at http://svn.php.net/viewvc/php/php-
src/trunk/ext/standard/string.c?view=markup#l7865, the default value
can
be expressed as ...
max(strlen($str), strlen($main_str) - $offset)
------------------------------------------------------------------------
[2010-02-10 01:07:53] guy dot paddock at gmail dot com
Description:
------------
The documentation for substr_compare() indicates that the default value
for the $length parameter is the string length of the $main_str
parameter, but this doesn't appear to be the case.
Reproduce code:
---------------
---
From manual page: function.substr-compare#Description
---
<?php
$a = "abc123";
$b = "abc";
echo "Is the documentation correct? ";
echo ((substr_compare($b, $a, 0) == (substr_compare($b, $a, 0,
strlen($b)))) ? 'true' : 'false');
echo "\n";
?>
Expected result:
----------------
Is the documentation correct? true
Actual result:
--------------
Is the documentation correct? false
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=50983&edit=1