23.03.2017 Views

wilamowski-b-m-irwin-j-d-industrial-communication-systems-2011

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Development of Interactive Web Pages 62-5<br />

{<br />

case 1:<br />

echo "One";<br />

break;<br />

case 2:<br />

echo "Two";<br />

break;<br />

case 3:<br />

echo "Three";<br />

break;<br />

default:<br />

echo "Try between one and three";<br />

}<br />

?><br />

62.3.3 Loops<br />

Loops are used to repetitively execute a block of code until or when a specific condition is true. Loops<br />

are used to perform the same task again and again so that we do not have to write several, almost equal<br />

statements.<br />

In PHP, loop statements such as while, do….while, and for are used differently depending on the<br />

condition.<br />

Example:<br />

//while statement.<br />

<br />

Output of above code: 1 2 3 4 5<br />

//do.....while statement<br />

<br />

Output: 2 3 4 5 6<br />

//for loop<br />

Syntax:<br />

for (init; condition; increment){<br />

code to be executed;<br />

}<br />

© <strong>2011</strong> by Taylor and Francis Group, LLC

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!