Bug->Doc #75331 [Opn]: [pt_BR] Old substr behavior when start after negative length

From: Date: Sat, 07 Oct 2017 07:39:43 +0000
Subject: Bug->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-15040@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: ERROR substr +Summary: [pt_BR] Old substr behavior when start after negative length Status: Open -Type: Bug +Type: Documentation Problem -Package: Scripting Engine problem +Package: Translation problem Operating System: LINUX e WINDOWS PHP Version: 7.0.24 Block user comment: N Private report: N New Comment: 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: - Previous Comments: ------------------------------------------------------------------------ [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

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