kphp icon indicating copy to clipboard operation
kphp copied to clipboard

substr function, remove return false

Open m-fedosov opened this issue 3 years ago • 0 comments

substr — Return part of a string

 substr(string $string, int $offset, ?int $length = null): string

Before PHP 8.0 if substr is empty, returns false

substr("abcdef", 4, -4);  // returns ""; prior to PHP 8.0.0, false was returned

In KPHP, because of this, you have to write additional conditions for translating false into an empty string. If this is fixed, the code becomes more readable and the behavior is more predictable.

m-fedosov avatar Dec 11 '22 14:12 m-fedosov