#50402 [Opn->Csd]: substr_compare emits no warning if length is equal to length of main_str

From: Date: Tue, 08 Dec 2009 09:29:42 +0000
Subject: #50402 [Opn->Csd]: substr_compare emits no warning if length is equal to length of main_str
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-3426@lists.php.net to get a copy of this message
ID: 50402 Updated by: rquadling@php.net Reported By: jcsahnwaldt at gmail dot com -Status: Open +Status: Closed Bug Type: Documentation problem PHP Version: Irrelevant 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: ------------------------------------------------------------------------ [2009-12-08 09:29:31] svn@php.net Automatic comment from SVN on behalf of rquadling Revision: http://svn.php.net/viewvc/?view=revision&revision=291868 Log: Corrected initializer for length. Expanded return values. Bug#50402 ------------------------------------------------------------------------ [2009-12-08 09:29:21] rquadling@php.net It seems that this should read ... "If offset is equal to or greater than the length of main_str or if length is set and is less than 1, ..." As offsets start at 0, an offset whose value is the length of the string is actually beyond the string. php -r "echo substr_compare('abcd', 'abcd', 4);" Warning: substr_compare(): The start position cannot exceed initial string length in Command line code on line 1 The error relates to "offset", not "length". ------------------------------------------------------------------------ [2009-12-07 20:54:23] jcsahnwaldt at gmail dot com Description: ------------ Incorrect: "If length is equal or greater than length of main_str" Correct: "If length is greater than length of main_str" Also see bug 37394 Reproduce code: --------------- --- From manual page: function.substr-compare#Return Values --- ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=50402&edit=1

« previous php.doc.bugs (#3426) next »