Funkcja dodawania dwóch liczb:



Kod:

    <form method="post">
      <label for="number1">Pierwsza liczba</label>
      <input type="number" name="number1" id="number1" require><br>
      <label for="number2">Druga liczba</label>
      <input type="number" name="number2" id="number2" require><br>
      <button>Kliknij</button>
    </form>
    <?php
      function add($number1, $number2) {
        return ($number1 + $number2);
      }

      if (isset($_POST['number1']) && isset($_POST['number2'])) {
        echo add($_POST['number1'], $_POST['number2']);
      }
    ?>