Using break to avoid division by zero : break statement « Statement « PHP
- PHP
- Statement
- break statement
Using break to avoid division by zero
<?php
$counter = -3;
for (; $counter < 10; $counter++){
if ($counter == 0){
echo "Stopping to avoid division by zero.";
break;
}
echo "100/$counter<br />";
}
?>
Related examples in the same category