One line if / else clause in PHP

Description:

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

Solution:

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.

About admin

Just another php developer trying to give something back to the community.
This entry was posted in PhP and tagged . Bookmark the permalink.

Leave a comment