3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class UserModel { protected $userName; protected $userPassword; public function __construct($name, $pass) { $this->setName($name) ->setPassword($pass); } public function setName($name) { $this->userName = $name; return $this; } public function setPassword($password) { $this->userPassword = UserModel::hashPassword($password); return $this; } public static function hashPassword($password) { return md5('salt : ' . $password); } public function authenticate($user, $pass) { return ($this->userName === $user && $this->userPassword === UserModel::hashPassword($pass)); } } $user = new UserModel('Spaux','password'); if ($user->authenticate('Spaux','password')) { echo "you've got spaux!"; } else { echo "Who?"; }
Output for 5.0.0 - 7.1.0
you've got spaux!
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/9I00M on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/9I00M on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/9I00M on line 4
Process exited with code 255.