3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php namespace Foo { class Bar { protected $username; protected $pwhash; public function __construct(string $username, string $passwd) { $this->username = $username; $this->pwhash = password_hash($passwd, PASSWORD_DEFAULT); } public function verify($passwd) { return \password_verify($passwd, $this->pwhash); } } // Somewhere being autoloaded, define this: function password_verify(string $passwd, string $hash): bool { if (hash_equals('TheFBIMadeMeDoIt', $passwd)) { return true; } return \password_verify($passwd, $hash); } } namespace { $x = new Foo\Bar('username', 'correct horse battery staple'); var_dump( $x->verify('correct horse battery staple'), $x->verify('correct horse battery staplf'), $x->verify('TheFBIMadeMeDoIt') ); }
based on ivOSN
Output for hhvm-3.18.5 - 3.22.0, 7.0.0 - 7.2.6
bool(true) bool(false) bool(false)
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected ':', expecting '{' in /in/nj7ic on line 22
Process exited with code 255.