How do empty () and isset () avoid warnings in undefined variables?

I know the concepts of Pass-by-value, Pass-by-reference, etc. So, I understand why explicitly defined functions raise a warning when a parameter is not defined.

But, if empty () and isset () are functions, then why doesn't it throw a warning when passing an undefined variable? Is there any kind of exceptional magic? How to do it?

+4
source share
1 answer

empty()and isset()are not actually functions.

They are keywords embedded in the language and executed by the compiler, and it is this behavior that is possible - the compiler (in contrast to the execution mechanism where ordinary functions are executed) already knows whether the variable exists or not.

, PHP 5 empty(), isset(), list() .. - const .

fexpr.

+3

Source: https://habr.com/ru/post/1686743/


All Articles