PHPBuilder - Quicker If

RSS Twitter

Quicker If

by: Richard Smith
August 31, 2001

Okay so you want to make a quick if in the middle of a string. You could to a quick function to return one value if a condition is true or another if the condition is false... Fear not!! No extra code required... Just do:

echo "You are" .(($LoggedIn) ? " logged in.. YaY!" : " logged out... poo! :(");

See... easy using the triniary operator. Take the following example:
$a ? $b : $c
If $a is true then $b will be returned, else $c will be returned...

Comment and Contribute

Your comment has been submitted and is pending approval.

Richard Smith



(Maximum characters: 1200). You have characters left.