3v4l.org

run code in 500+ PHP versions simultaneously
<form method='POST' action=""> towar:<input type='text' name='a'><br> ilość:<input type='text' name='b'><br> cena:<input type='text' name='c'><br> <input type='submit' name='s' value='LICZ'> </form> <?php if(isset($_POST['s'])){ class Odpowiedz{ public $towar; public $ilosc; public $cena; public function __construct($towar, $ilosc, $cena){ $this->towar = $towar; $this->ilosc = $ilosc; $this->cena = $cena; } public function zdanie(){ $suma = $this->ilosc * $this->cena; echo "Za $this->towar w ilości $this->ilosc należy zapłacić $suma zł."; } } $zdanie2 = new Odpowiedz($_POST['a'], $_POST['b'], $_POST['c']); $zdanie2->zdanie(); } ?>
Output for 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
<form method='POST' action=""> towar:<input type='text' name='a'><br> ilość:<input type='text' name='b'><br> cena:<input type='text' name='c'><br> <input type='submit' name='s' value='LICZ'> </form>

preferences:
40.3 ms | 714 KiB | 4 Q