php selection looping statements
Download
Skip this Video
Download Presentation
PHP Selection & Looping Statements

Loading in 2 Seconds...

play fullscreen
1 / 15

PHP Selection & Looping Statements - PowerPoint PPT Presentation


  • 110 Views
  • Uploaded on

PHP Selection & Looping Statements. Control Structures. Programming Languages commonly include a number of “control structures”, that allow users to execute based on evaluation. Blocks of statements are enclosed in curly brackets ({}). PHP includes the following control structures: IF-ELSE

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'PHP Selection & Looping Statements' - wyatt


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
control structures
Control Structures

Programming Languages commonly include a number of “control structures”, that allow users to execute based on evaluation. Blocks of statements are enclosed in curly brackets ({}). PHP includes the following control structures:

  • IF-ELSE
  • WHILE
  • FOR
  • SWITCH
control structure 1 if else
Control Structure #1IF-ELSE

*NOTE: the else is optional

if statements
if Statements

if ($number > 10)

echo “That is a big number”;

if ($number > 10)

{

echo “
The number is greater than 10.”;

echo “
So, it must be big.”;

}

if ($number > 10)

echo “
That’s a big number.”;

else

echo “
That’s a small number.”;

if statements1
if Statements

if ($number > 10)

{

echo “
The number is greater than 10.”;

echo “
So, it must be big.”;

}

else

{

echo “
The number is less or equal to 10.”;

echo “
So, it must be small.”;

}

if statements2
if Statements

if ($number > 10)

if ($number > 100)

echo “
That is a very big number.”;

else

{

echo “
The number is greater than 10.”;

echo “
So, it must be big.”;

}

else

echo “
That is a small number.”;

if statements3
if Statements

if ($number > 100)

echo “
That’s a very big number.”;

elseif ($number > 10)

echo “
That is a big number.”;

elseif ($number > 1)

echo “
That is a small number.”;

else

echo “
That is a very small number.”;

switch statement
switch Statement

switch ($number)

{

case 1:

echo “small”;

break;

case 2:

echo “medium”;

break;

case 3:

echo “large”;

break;

default:

echo “That is not a valid code.”;

}

for statement
for statement

$sum = 0;

for ($n=1; $n<=3; $n++)

$sum += $n;

echo “
The sum of the integers from 1 to $number is $sum.”;

control structure 3 while
Control Structure #3WHILE

NOTE: $timeleft- - is equivalent to $timeleft = $timeleft -1

while statement
while statement

$n = 0;

$sum = 0;

while ($n <=3)

{ $sum = $sum + $n;

$n++;

}

echo “The sum is $sum”;

ad