Tuesday, November 21, 2006

My if ... else Shortcut

I am always forgetting how to do this shortcut in PHP so I figured if I post it I will always have it.

(condition ? value if true : value if false)

if ($iamcool==true) {
$x=1;
} else {
$x=2;
}

is the same as
if ($imamcool==true) : $x=1 ? $x=2;

No comments: