Why isn't this working?
$a = 'FOO';
$foo = $a ? &$a : 'whatever'; // <- error here
echo $foo;
I get a parse error :|
If you want to assign a reference using a ternary statement, then you need this clumsy workaround:
list($foo) = $a ? array(&$a) : array('whatever');
However, as said in the other answers, this seldomly saves memory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With