Control Structures
Control Structures
if, else
if(<boolean expression>)
{
pass logic
}
else
{
alternative logic
}// Global variable that controls lighting
$lightsShouldBeOn = true;
// Check to see if lights should be on or off
if($lightsShouldBeOn)
{
// True. Call turn on lights function
turnOnLights();
echo("Lights have been turned on");
}
else
{
// False. Turn off the lights
turnOffLights();
echo("Lights have been turned off");
}switch, switch$
for
foreach
while
Last updated