#50983 [Opn->Ver]: default value for $length parameter of substr_compare() is incorrect in docs
| From: | rquadling@php.net | Date: | Wed, 10 Feb 2010 10:58:25 +0000 |
| Subject: | #50983 [Opn->Ver]: 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-3855@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: Open
+Status: Verified
Bug Type: Documentation problem
Operating System: Debian Etch
PHP Version: 5.2.12
New Comment:
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)
Previous Comments:
------------------------------------------------------------------------
[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