> echo blank(" "); // true This case is not blank `empty` checks if a variable is set and contains something so basically what your blank function does. In this example it contains character 32. If you want to remove the "\0" (null terminator) from the language, that's a different story.
On Sat, Apr 5, 2025 at 9:45 PM Rob Landers <rob@bottled.codes> wrote: > On Sat, Apr 5, 2025, at 20:25, Bilge wrote: > > On 05/04/2025 15:32, Kamil Tekiela wrote: > > > > While it has its uses empty() should be avoided whenever possible. > > > Agree. A better RFC would be to just deprecate `empty()`. > > Cheers, > Bilge > > > empty() has very many uses. Once you understand what it is shorthand for, > it makes a lot of sense to use it how it was meant to be used. For example: > > empty($var) ?: foo($var); > > which is just shorter than: > > if (isset($var) && $varl != false) { > foo($bool); > } > > Generally, you don't use empty() on strings though, just arrays, in my > style guides anyway. For strings, you use `$string == ""` or to be more > proper, maybe > > trim($value ?? '') == '' > > ... but these days, trim doesn't accept `null`, so that makes it a bit > more wordy than it really should be. However, it is just a deprecation > notice, so it is easy to ignore. For now. > > — Rob > -- Iliya Miroslavov Iliev i.mirosla...@gmail.com