3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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->password() && $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 = 'login'; } 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.2.0
<h1>Witam w banku DSC SA.</h1><p>Prosze wprowadzic login: </p><p>Prosze wprowadzic haslo: </p><p>Prosze wprowadzic PIN: </p> Fatal error: Uncaught Error: Call to undefined method ATM::password() in /in/pTRev:28 Stack trace: #0 /in/pTRev(66): ATM->checkBalance(1234, 'secret', 'admin') #1 {main} thrown in /in/pTRev on line 28
Process exited with code 255.
Output for 5.3.22 - 5.6.28
Warning: Unsupported declare 'strict_types' in /in/pTRev on line 2 Catchable fatal error: Argument 1 passed to ATM::checkBalance() must be an instance of int, integer given, called in /in/pTRev on line 66 and defined in /in/pTRev on line 12
Process exited with code 255.