3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* receive form data: $username = (!empty(POST['username']))? POST['username'] : null; $password = (!empty(POST['password']))? POST['password'] : null; $user_hash = (!empty(POST['user_hash']))? POST['user_hash'] : null; By Prince Adeyemi */ //Login with received data $username = "myLogin"; $password = "letmein"; $user_hash = "hash12345"; // Alter this hash to Prompt for Verification. $user = new login($username, $password, $user_hash); Class login { private $_loggedIn = false; private $_username = null; private $_password = null; private $_userhash = null; function __construct(string $user, string $password, string $user_hash) { $this->_username = trim($user); $this->_password = trim($password); $this->_userhash = trim($user_hash); $this->login_user($this->_username, $this->password); } private function login_user(string $user, string $pass) { $this->login($this->_username, $this->password); } private function login(string $username, string $password) : bool { echo "Login using Username $this->_username and password $this->_password"; $this->_loggedIn = $this->isloggedIn(); if($this->_loggedIn) { echo "\nLogin Successfully"; $this->compare($this->_userhash); } else{ echo "\nLogin failed!"; } return $this->__get($this->_username); } private function compare($new_hash) { $stored_hash = "hash12345"; $hashed_verify = ($new_hash === $stored_hash) ? true : false; if(!$hashed_verify) { $this->_loggedIn = false; $this->_doSecurity($this->_username); } else{ echo"\nHash matched sending user : $this->_username to USER_DASHBOAD"; } } private function _doSecurity($user) { echo "\nHash not matched, commencing security verification for $this->_username"; } private function isLoggedIn():bool { //..check if logged in, or set loggedIn to false. $this->_loggedIn = (($this->_username == "myLogin") && ($this->_password=="letmein") ) ? true : $this->_loggedIn ; return $this->__get($this->_username); } public function __get($userLoggedIn) :bool { return $this->_loggedIn; } }
Output for 7.1.0 - 7.1.23, 7.2.0 - 7.2.33, 7.3.16 - 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.4, 8.3.6
Login using Username myLogin and password letmein Login Successfully Hash matched sending user : myLogin to USER_DASHBOAD
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Login using Username myLogin and password letmein Login Successfully Hash matched sending user : myLogin to USER_DASHBOAD
Output for 5.6.38
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/pGlDu on line 42
Process exited with code 255.

preferences:
142.74 ms | 401 KiB | 173 Q