SHARE
TWEET

Form-SumTwoNumbers

-Annie- Jul 17th, 2017 40 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php  declare(strict_types=1) ?>
  2.     <form>
  3.         Number1: <input type="number" value="0" name="num1"/> </br>
  4.         Number2: <input type="number" value="0" name="num2"/> </br>
  5.         <input type="submit" value="Sum" name="sum-btn" />
  6.     </form>
  7. <?php
  8. function sum(int $a, int $b): int {
  9.     return $a + $b;
  10. }
  11.  
  12. if (isset($_GET['sum-btn'])) {
  13.     $a = intval($_GET['num1']);
  14.     $b = intval($_GET['num2']);
  15.     echo sum($a, $b);
  16. }
RAW Paste Data
Top