Screen Shot for Thumnbails


Conn Warwicker



Portfolio

Scripts and Websites I've made using PHP and MySQL mainly.

Snippets

Code snippets and mini tutorials

Contact

Contact me if you have any questions or queries



Home / Snippets / if_else_shorthand

This section is new and undergoing snippet addition, as of 13/6/11

If/Else Shorthand



Syntax: (conditional) ? if met : else;

Some examples of the normal if/else format:

if($x === 0)
{
$y = 1;
}
else
{
$y = -1;
}

//..

if(strlen($str) > 100)
{
echo $str;
}
else
{
echo "Too Short";
}


What they become using shorthand:

($x === 0) ? $y = 1 : $y = -1;

echo (strlen($str) > 100) ? $str :  "Too Short";


Leave a Comment


Comment

All fields are required

Your Name


Your Email Address


Your Comment


Human Validation

What animal is this above:






Comments


No Comments Have Been Made