#native_company# #native_desc#
#native_cta#

Quicker If

By Richard Smith
on 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…