On 5 April 2025 21:00:15 BST, Rob Landers <rob@bottled.codes> wrote:

>I agree with most of these. I do not agree that " " (a space) is blank though. 
>For people without last names, this is often their last name to pass 
>validation on forms. 

This is firmly into "space-bar heating" [https://xkcd.com/1172/] territory - 
failure to trim whitespace before validation is a common bug, and requiring a 
name in exactly two boxes is a common design/localisation failure, but neither 
justifies the other.

I think a function for "string is zero length or contains only whitespace" 
would potentially be useful, but am not convinced it needs to accept any other 
type, or have the error-suppression power of isset/empty - adding ??'' inside a 
function call is not a big burden for new code.

That said, I just realised there is a ctype_space function, and I've never used 
it or seen it used; normally, trim($foo)==='' (or trim($foo??'')==='') seems to 
be good enough.

Rowan Tommins
[IMSoP]

Reply via email to