Advertisement
cesarcardinale

M3014 Prog web - TD1 - calcul.php

Sep 17th, 2018
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.58 KB | None | 0 0
  1. <?php
  2. function start_page($title)
  3. {
  4. echo ' <!DOCTYPE html>
  5.       <html lang="fr">
  6.       <head><title>' . PHP_EOL . $title . '</title></head>
  7.       <body>' . PHP_EOL
  8. ;
  9. };
  10.  
  11. function end_page()
  12. {
  13. echo '</body>
  14.      </html>' . PHP_EOL
  15. ;
  16. };
  17.  
  18. start_page('Premier pas en PHP');
  19.  
  20. $op1 = $_POST['op1'];
  21. $op2 = $_POST['op2'];
  22. $op = $_POST['action'];
  23.  
  24. if('*' == $op){
  25.   echo $op1 * $op2;
  26. }
  27. elseif('+' == $op){
  28.   echo $op1 + $op2;
  29. }
  30. elseif('-' == $op){
  31.     echo $op1 - $op2;
  32. }
  33. else{
  34. echo '<br/><strong>opérateur ' . $op . ' non géré </strong>';
  35. }
  36.  
  37. end_page();
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement