"Both while and for statements incorporate a built-in test expression with which you can end a loop. However, the breat statement enab les you to break out of a loop based on the results of additional tests. This can safeguard agains error." (121) The danger often arises when the counter variable comes from user input. This may result in an effort to use a negative number, or a string, either of which would not be desirable: division by zero results in an answer of "undefined", and a string can not be divided mathematically. (WHAT HAPPENS?)
<?php
for ($counter=1; $counter <= 10; $counter++) {
$temp = 4000/$counter;
echo "4000 divided by ".$counter." is...".$temp."<br />";
}
?>