Why does empty expect T_PAAMAYIM_NEKUDOTAYIM when a non-variable is given?

constants, php, variables

Solution

The next logical thing the parser wants is a `::` because `foo` is not a variable.

if (empty(foo::$bar)) {
}

Is the only thing, that works when `empty()` is not passed a variable. Your example is evaluated as `empty(bar)` where the parser assumes `bar` to be a class name and now expects a static member variable.

Problem

``` <?php define('foo', 'bar'); if (empty(foo)) { echo 'qux'; } ``` http://codepad.org/G1TSK1c6 Parse error: syntax error, unexpected ')', expecting T_PAAMAYIM_NEKUDOTAYIM on line 4 I know that `empty()` only allows variables to be passed as an argument, but why does it expect a T_PAAMAYIM_NEKUDOTAYIM (i.e. `::`) when I give it a constant?

Original source