PHP if statement in shorthand
Another “tired of hunting for the exact syntax” things… Here’s shorthand for an “if” statement:
echo isset($var) ? $var : "sorry, nothing here";
Another “tired of hunting for the exact syntax” things… Here’s shorthand for an “if” statement:
echo isset($var) ? $var : "sorry, nothing here";
February 8th, 2007 at 12:22 pm
Also called a ternary operator. The outer parentheses can be dropped, too.