Advertisement
H4nk

kalkulator

May 28th, 2013
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Operators PHP</title>
  4. </head>
  5. <body>
  6. <h2>Contoh Penggunaan Operator pada PHP</h2>
  7. <form action="#" method="post">
  8. <input type="text" name="operand1" value="0" />
  9. <select name="operator">
  10. <option value="-">pengurangan(-)</option>
  11. <option value="+">pertambahan(+)</option>
  12. <option value="/">pembagian(/)</option>
  13. <option value="*">perkalian(*)</option>
  14. <option value="%">prosentase(%)</option>
  15. </select>
  16. <input type="text" name="operand2" value="0" />
  17. <input type="submit" name="proses" value="Proses" />
  18. </form>
  19. <?php
  20. error_reporting(0);
  21. $hitung=$_POST['operand1'].$_POST['operator'].$_POST['operand2'];
  22. $hasil = eval("return($hitung);");
  23. echo("Hasil Perhitungan Matematika : ");
  24. echo $hasil;
  25. ?>
  26. </body>
  27. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement