zircote.com

development (in)action

A Quick Ternary Joyride.

I am not a fan of @ but I have not found a way to use the new ternary operator without otherwise throwing the notice.

[ zircote ~/Workspace/CtaTrack ] php -a
Interactive shell

php > $v = array();
php > echo $v['test']?: 'no';
PHP Notice:  Undefined index: test in php shell code on line 1
no
php > echo @$v['test']?: 'no';
no
php > $v['test'] = 'yes';
php > echo @$v['test']?: 'no';
yes
php >