Skip to content
Discussion options

You must be logged in to vote

As you quoted empty does "!isset($var) || $var == false". This is a loose comparison with false, it's kind of the definition of non-strict :D

In effect, what will be considered empty here is:
undefined variable (not really applicable for your example given the function call)
null
empty string
"0"

Do you want the string which contain the character "0" to be considered empty while the string " " is not empty? Maybe. Does the semantics of your code helps anyone to understand what you wanted to check or not? I'd say no.

There's a lot of built-in things in PHP I'd discourage from using. Empty sits pretty high on this list...

There's currently no way to disable this inspection only for the empt…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Abdillah
Comment options

@orklah
Comment options

orklah Aug 6, 2025
Collaborator

@Abdillah
Comment options

Answer selected by Abdillah
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants