Precies, die had ik dan ook toegevoegd, plus een check op deling door 0:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>acos</title>
<style type="text/css">
h1 {
font: 18px georgia;
color: #acb;
}
p, input {
font: 12px verdana;
}
</style>
</head>
<body>
<h1>Bereken de arccosinus aan de hand van twee getallen</h1>
<form method="post" action="#">
<p>
<label for="zijderechts">zijde rechts:</label>
<input id="zijderechts" name="zijderechts" type="text">
<label for="zijdeschuin">zijde schuin:</label>
<input id="zijdeschuin" name="zijdeschuin" type="text">
<input type="submit" value="go">
</p>
</form>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (ctype_digit ($_POST['zijderechts']) && ctype_digit ($_POST['zijdeschuin'])) {
$rechts = floatval ($_POST['zijderechts']);
$schuin = floatval ($_POST['zijdeschuin']);
if ($schuin) {
$getal = $rechts / $schuin;
if ($getal >= -1 && $getal <= 1) {
echo '<p>Arccosinus: ' . rad2deg (acos ($rechts / $schuin)) . '</p>';
}
else {
echo '<p>Je kunt niet de arccosinus berekenen van ' . number_format ($getal, 2) . '</p>';
}
}
else {
echo '<p>De waarde voor zijde schuin mag geen 0 zijn.</p>';
}
}
}
?>
</body>
</html>
Link gekopieerd
Ok, bedankt allemaal, ik ga morgen weer verder, ontwikkelingen op dit script kun je vinden op:
www.arcome.nl/wiskunde
Link gekopieerd