Computing Magazine

One Line If / Else Clause in PHP

Posted on the 29 March 2012 by Akahgy


Create an “if / else” check in one line.


For assigning a value, or triggering a special function based on an “if / else” clause we can use the one line clause from PHP:

$our_variable = (is_this_true()) ? “value in case of true” : “value in case of false”;


Where is_this_true() is the function or variable that has to be checked for validity.

Back to Featured Articles on Logo Paperblog