php - Why does empty expect T_PAAMAYIM_NEKUDOTAYIM when a non-variable is given? -
<?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 empty() allows variables passed argument, why expect t_paamayim_nekudotayim (i.e. ::) when give constant?
the next logical thing parser wants :: because foo not variable.
if (empty(foo::$bar)) { } is thing, works when empty() not passed variable. example evaluated empty(bar) parser assumes bar class name , expects static member variable.
Comments
Post a Comment