Learning PHP and MySQL
Example 04-16 Using break to avoid division by zero
<?php
$counter = -3;
for (; $counter < 10; $counter++){
// Check for division by zero
if ($counter == 0){
echo "Stopping to avoid division by zero.";
break;
}
echo "100/$counter<br/>";
}
?>
Posted by on 08/03 at 08:16 AM
Next entry: Example 05-01 The ubiquitous Hello world!
Previous entry: Example 04-15 Counting to 10 with do… while