26 lines
591 B
PHP
26 lines
591 B
PHP
<?php
|
|
|
|
if (isset($_GET['a']) && isset($_GET['b'])) {
|
|
$a = $_GET['a'];
|
|
$b = $_GET['b'];
|
|
echo "Versuch der Division zweier Zahlen.<br>" . "Werfen einer Ausnahme, " . "wenn Division durch 0 zu teilen.<hr> ";
|
|
try {
|
|
|
|
if ($b == 0)
|
|
throw new Exception("<hr>Keine Division durch 0 erlaubt<hr>");
|
|
echo $a / $b . "<br>";
|
|
} catch(Exception $e) {
|
|
print_r($e);
|
|
}
|
|
|
|
echo "<hr>Nach dem potenziellen Problem. ";
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<form >
|
|
Wert 1: <input name="a"><br>
|
|
Wert 2: <input name="b"><br>
|
|
<input type="submit">
|
|
</form>
|