Ternary operater in PHP5.3
according to php.net; "Since PHP 5.3, it is possible to leave out the middle part of the ternary operator. Expression expr1 ?: expr3 returns expr1 if expr1 evaluates to TRUE, and expr3 otherwise."
So, in the following line, if there is set a $POST['test'], the variable will contain the value of $POST['test']. If there's no $_POST'test', $test will contain the boolean value FALSE.
$test = $_POST['test'] ?: false;
Not exactly rocketsurgery, but it saves a few keystrokes and (imho) looks 'cleaner'.
Written by Jeroen Kornegoor
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Related Tags
#php5.3
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#