Search Header Logo
Testing Lesson

Testing Lesson

Assessment

Presentation

Computers

9th Grade

Practice Problem

Hard

Created by

Julie Rhoades

Used 2+ times

FREE Resource

8 Slides • 0 Questions

1

media

M2 L1 PHP

2

media

Overview

Use conditional statements

if
if...else
switch

Nested statements

2

3

media

if Statements

Syntax for a simple if statement is:

if (conditional expression)

statement;

If more than 1 statement, they must be in

a block { }

Recommendation: Always include { } to

cut down on errors

3

Indent

for readability
and less errors

4

media

if Statements, Example

$ExampleVar = 5;
if ($ExampleVar == 5) {

echo "<p>Evaluated to true.</p>";
echo "<p>So these lines print.</p>”;
}

echo "<p>This statement always executes.</p>";

4

Opening and Closing braces.
Needed for a command block

5

media

if...else Statements

Syntax:

if (conditional expression)

statement;

else

statement;

Example:

$Today = "Tuesday";
if ($Today == "Monday") {

echo "<p>Today is Monday</p>";

}
Else {

echo "<p>Today is not Monday</p>";

}

5

6

media

Nested Statements

One decision-making statement is

contained within another

$SalesTotal = 60;
if ($SalesTotal > 50){

if ($SalesTotal < 100){

echo "<p>Sales between 50 & 100.</p>";

}

}

6

7

media

switch Statements

$AmericanCity = "Chicago";
switch ($AmericanCity) {

case "Miami":

Echo "Florida";
break;

case "Chicago":

Echo "Illinois";
break;

case "Los Angeles":

Echo "California";
break;

default:

Echo "United States";

}

7

Break command ends a switch
statement. Needed because
the switch statement does not
automatically stop after a case
match.

Expression

Case Label and value

Default – if no
match above

8

media

Summary

Use conditional statements

if
if...else
switch

Nested statements

8

media

M2 L1 PHP

Show answer

Auto Play

Slide 1 / 8

SLIDE