affiche l'écran d'une calculatrice
Posté : 26 mars 2015, 15:18
Bonjour, je viens de commencer le php et j'aimerai réaliser une calculatrice basique. je suis bloqué au niveau de l'affichage de l'expression arithmétique de saisie du clavier. je voudrai afficher toutes les saisies du clavier avant d’évaluer l'expression
voici mon code:
voici mon code:
<!doctype html>
<html lang="fr">
<head>
<title>Calculatrice</title>
<meta charset="utf-8">
<style>
table { border-collapse:collapse; }
table,td { border:1px solid black; font-family:monospace;}
td { padding:15px; }
a { text-decoration:none; }
</style>
</head>
<body>
<h2>Calculatrice</h2>
<table>
<tr>
<td><a href="calculatrice.php?fonction=e">E</a></td>
<td><a href="calculatrice.php?fonction=c">C</a></td>
<td><a href="calculatrice.php?touche=%28">(</a></td>
<td><a href="calculatrice.php?touche=%29">)</a></td>
</tr>
<tr>
<td><a href="calculatrice.php?touche=7">7</a></td>
<td><a href="calculatrice.php?touche=8">8</a></td>
<td><a href="calculatrice.php?touche=9">9</a></td>
<td><a href="calculatrice.php?touche=%2B">+</a></td>
</tr>
<tr>
<td><a href="calculatrice.php?touche=4">4</a></td>
<td><a href="calculatrice.php?touche=5">5</a></td>
<td><a href="calculatrice.php?touche=6">6</a></td>
<td><a href="calculatrice.php?touche=-">-</a></td>
</tr>
<tr>
<td><a href="calculatrice.php?touche=1">1</a></td>
<td><a href="calculatrice.php?touche=2">2</a></td>
<td><a href="calculatrice.php?touche=3">3</a></td>
<td><a href="calculatrice.php?touche=%2A">*</a></td>
</tr>
<tr>
<td><a href="calculatrice.php?touche=0">0</a></td>
<td><a href="calculatrice.php?touche=%2C">,</a></td>
<td><a href="calculatrice.php?touche=%3D">=</a></td>
<td><a href="calculatrice.php?touche=%2F">/</a></td>
</tr>
</table>
<p><b>Expression:</b> <?php
$expression='';
if (isset($_GET['touche']))
{$expression.=$_GET['touche'] ;
}echo $expression;
?>
<p><b>Résultat:</b> </p>
</body>
</html>