php » Conditional Statements

switch

switch ($type){
case “food”:
//delete
break;
case “food”:
//delete
break;
default:
//code to be executed if expression is different from both label1 and label2;
}

Posted by Mark on April 18th, 2009 under Conditional Statements  •  No Comments

Short IF syntax

echo ($name==”Some Name”) ? “Name Matches!” : “Name Doesn’t Match”

//You can also do more complex and inline:
$text = “There “. ($total==1 ? “is 1 item” : “are “.($total == 0 ? “no items” : “$total items”) );

Posted by Mark on April 18th, 2009 under Conditional Statements  •  2 Comments