Doc #73613 [Opn]: Not warning if length == 0
| From: | nikic@php.net | Date: | Sun, 27 Nov 2016 09:25:08 +0000 |
| Subject: | Doc #73613 [Opn]: Not warning if length == 0 | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-14147@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73613&edit=1
ID: 73613
Updated by: nikic@php.net
Reported by: ua dot san dot alex at gmail dot com
Summary: Not warning if length == 0
Status: Open
Type: Documentation Problem
Package: Strings related
PHP Version: 7.1.0RC6
Block user comment: N
Private report: N
New Comment:
To add to this, the reason is that substr_count() now also accepts a negative length parameter with
the usual meaning. We could still explicitly exclude the case length=0, but, as @requinix mentions,
it doesn't really make sense. We allow length=0 elsewhere and it is useful if $length is not a
hardcoded value.
Previous Comments:
------------------------------------------------------------------------
[2016-11-27 04:46:11] requinix@php.net
The documentation doesn't say the function gives warnings. Other string functions do not give
warnings when $length=0. substr_count should not give warnings.
But the change is not documented - not in the substr_count docs (eg, in the Changelog) or in the 7.1
migration guide's "Changed functions" list.
------------------------------------------------------------------------
[2016-11-27 00:04:19] ua dot san dot alex at gmail dot com
Description:
------------
Not warning if length == 0
https://3v4l.org/jcDIo
Test script:
---------------
<?php
substr_count('haystack', 'needle', 0, 0);
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73613&edit=1