3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); class ATM { private $trials = 3; private $balance = 100; private $password; private $login; private $pin; public function checkBalance(int $pin, string $password, string $login) { echo '<h1>Witam w banku DSC SA.</h1>'; $this->getPassword(); echo '<p>Prosze wprowadzic login: </p>'; $this->getLogin(); echo '<p>Prosze wprowadzic haslo: </p>'; $this->getPassword(); echo '<p>Prosze wprowadzic PIN: </p>'; $this->getPin(); if ($pin == $this->getPin() && $password == $this->getPassword() && $login == $this->getLogin() ) { echo "Poprawne dane" . PHP_EOL; echo "Saldo konta wynosi: {$this->balance}"; } else { $this->trials--; echo "Niepoprawne dane" . PHP_EOL; echo "Pozostalo {$this->trials} proby"; } } public function getBalance() { return $this->balance = 100; } public function getTrials() { return $this->trials; } private function getLogin() { return $this->login = 'admin'; } private function getPassword() { return $this->password = 'secret'; } private function getPin() { return $this->pin = 1234; } } $banco = new ATM(); $banco->checkBalance(1234, 'secret', 'admin');
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
<h1>Witam w banku DSC SA.</h1><p>Prosze wprowadzic login: </p><p>Prosze wprowadzic haslo: </p><p>Prosze wprowadzic PIN: </p>Poprawne dane Saldo konta wynosi: 100
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Warning: Unsupported declare 'strict_types' in /in/5jtsB on line 2 Catchable fatal error: Argument 1 passed to ATM::checkBalance() must be an instance of int, integer given, called in /in/5jtsB on line 66 and defined in /in/5jtsB on line 12
Process exited with code 255.

preferences:
197.24 ms | 402 KiB | 330 Q