From 343a1fc27f442f0772cbfe01ff35ab62c5f78d86 Mon Sep 17 00:00:00 2001 From: Mikhail Alferov Date: Fri, 4 Jul 2025 17:58:08 +0300 Subject: [PATCH] substr.xml Remove the redundant mention of the offset The function first determines the starting position of the substring (part of the original string), and then drops abs($length) characters from the tail of this substring if the value of the $length parameter is negative. I don't understand the meaning of the parenthesized notation, and it seems redundant to me; as if the $length parameter behaves differently with a positive offset. My point is that with a negative value of the $offset parameter, the behavior of the $length parameter does not change, so why mention the negative offset separately. Moreover, the end of the original string and the end of the substring that remained after applying the offset are the same ends, no matter how you look at it, and it is from these ends that the function will discard characters. --- reference/strings/functions/substr.xml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/reference/strings/functions/substr.xml b/reference/strings/functions/substr.xml index 2f72222d9a1a..321b546b133a 100644 --- a/reference/strings/functions/substr.xml +++ b/reference/strings/functions/substr.xml @@ -80,10 +80,8 @@ echo substr("abcdef", -3, 1), PHP_EOL; // returns "d" If length is given and is negative, then that many - characters will be omitted from the end of string - (after the start position has been calculated when a - offset is negative). If - offset denotes the position of this truncation or + characters will be omitted from the end of string. + If offset denotes the position of this truncation or beyond, an empty string will be returned.