3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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 = "hash123451"; // 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; } }
based on pGlDu
Output for 7.0.28 - 7.3.0rc3
Login using Username myLogin and password letmein Login Successfully Hash not matched, commencing security verification for myLogin
Output for 5.6.38
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/R9UQg on line 42
Process exited with code 255.