11.07.2015 Views

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

www.it-ebooks.infoCHAPTER 3 • <strong>PHP</strong> BASICSThe while StatementThe while statement specifies a condition that must be met before execution of its embedded code isterminated. Its syntax is the following:while (expression) {statements}In the following example, $count is initialized to the value 1. The value of $count is then squared andoutput. The $count variable is then incremented by 1, and the loop is repeated until the value of $countreaches 5.The output looks like this:1 squared = 12 squared = 43 squared = 94 squared = 16Like all other control structures, multiple conditional expressions may also be embedded into thewhile statement. For instance, the following while block evaluates either until it reaches the end-of-fileor until five lines have been read and output:Given these conditionals, a maximum of five lines will be output from the sports.txt file, regardlessof its size.81

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

Saved successfully!

Ooh no, something went wrong!