Doc #75331 [Opn]: [pt_BR] Old substr behavior when start after negative length
| From: | requinix@php.net | Date: | Sat, 07 Oct 2017 07:44:18 +0000 |
| Subject: | Doc #75331 [Opn]: [pt_BR] Old substr behavior when start after negative length | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-15042@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75331&edit=1
ID: 75331
Updated by: requinix@php.net
Reported by: jandelson_oliveira at yahoo dot com dot br
Summary: [pt_BR] Old substr behavior when start after
negative length
Status: Open
Type: Documentation Problem
Package: Translation problem
Operating System: LINUX e WINDOWS
PHP Version: 7.0.24
Block user comment: N
Private report: N
New Comment:
> Those docs still say $rest1 should be false
Backwards: they say empty string, should be false.
Previous Comments:
------------------------------------------------------------------------
[2017-10-07 07:43:13] requinix@php.net
...
Also missing a few comments: when length is given and 0/false/null, when length is omitted, returns
false on failure or empty string, and the Changelog.
------------------------------------------------------------------------
[2017-10-07 07:39:36] requinix@php.net
Works correctly according to the EN docs. https://3v4l.org/rgStf
$rest is false because "length is given and is negative" and "start denotes the
position of this truncation or beyond".
$rest1 is an empty string (not null) because "string is equal to start characters long"
(6) and "length is given and is positive".
http://php.net/manual/en/function.substr.php
But I do see some errors in the pt_BR docs, so I'm repurposing this bug for them.
Those docs still say $rest1 should be false:
- EN: If start denotes the position of this truncation or beyond, FALSE will be returned.
- pt_BR: Se start denota uma posição além da truncagem, uma string vazia será retornada.
And the example needs adjustment:
- EN: $rest = substr("abcdef", 4, -4); // returns false
- pt_BR: $rest = substr("abcdef", 4, -4); // retorna ""
Also:
-
------------------------------------------------------------------------
[2017-10-07 02:20:29] jandelson_oliveira at yahoo dot com dot br
Description:
------------
we notice a bug in the return of the substr when it does not find the position in the analyzed
string
as in the documentation informs that when it does not find the value the return is false but in php7
the return is not always false.
Test script:
---------------
$rest = substr("abcdef", 6, -2);
$rest1 = substr("abcdef", 6, 4);
var_dump($rest);
var_dump($rest1);
Expected result:
----------------
we notice a bug in the return of the substr when it does not find the position in the analyzed
string
as in the documentation informs that when it does not find the value the return is false but in php7
the return is not always false.
Actual result:
--------------
false and null
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75331&edit=1