By harlan
via php.dzone.com
Published: Jan 23 2008 / 13:51
In looking at my Google Analytics statistics, I see a lot of visitors searching for PHP shorthand if/else (ternary) information. I've gone through my code library and picked out some examples of ternary operator usage.
Comments
antych replied ago:
If you are showing off shorthand, you should know that
$is_admin = ($user['permissions'] == 'admin' ? true : false);
is the same as
$is_admin = ($user['permissions'] == 'admin');
== operator already returns boolean value!
Voters For This Link (14)
Voters Against This Link (0)