3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $RANDOM_SALT = 0; //rand(); function saltedHash($pass) { global $RANDOM_SALT; return hash("sha512", $pass) + $RANDOM_SALT; } $USERS = [ "user1" => saltedHash("password1"), "user2" => saltedHash("hunter2"), "user3" => saltedHash("fN.4A_zKEe]33p!"), "user4" => saltedHash("xXgjan3a58qzX3"), ]; function checkLogIn($username, $password) { global $USERS; $hashedPassword = saltedHash($password); $expectedPassword = $USERS[$username]; echo " H: $hashedPassword\n E: $expectedPassword\n"; echo "User '$username' has password '$password'? "; if ($hashedPassword === $expectedPassword) { echo "yes\n"; } else { echo "no\n"; } } // ==== TEST CODE: ==== checkLogIn("user1", "phplol"); checkLogIn("user1", "password1"); echo "\n"; checkLogIn("user2", "phplol"); checkLogIn("user2", "hunter2"); echo "\n"; checkLogIn("user3", "phplol"); checkLogIn("user3", "FN4A_zKEe]33p!"); echo "\n"; checkLogIn("user4", "phplol"); checkLogIn("user4", "xXgjan3a58qzX3"); echo "\n"; echo "Now let's get funky!"; checkLogIn("user3", "password1"); checkLogIn("user3", "fN.4A_zKEe]33p!"); checkLogIn("user3", "fN.4A_zKEe]33p!");
based on DGME5
Output for 7.1.0 - 7.2.0
Warning: A non-numeric value encountered in /in/Y9aPg on line 6 Notice: A non well formed numeric value encountered in /in/Y9aPg on line 6 Warning: A non-numeric value encountered in /in/Y9aPg on line 6 Notice: A non well formed numeric value encountered in /in/Y9aPg on line 6 Notice: A non well formed numeric value encountered in /in/Y9aPg on line 6 H: 1 E: 0 User 'user1' has password 'phplol'? no Warning: A non-numeric value encountered in /in/Y9aPg on line 6 H: 0 E: 0 User 'user1' has password 'password1'? yes Notice: A non well formed numeric value encountered in /in/Y9aPg on line 6 H: 1 E: 6 User 'user2' has password 'phplol'? no Notice: A non well formed numeric value encountered in /in/Y9aPg on line 6 H: 6 E: 6 User 'user2' has password 'hunter2'? yes Notice: A non well formed numeric value encountered in /in/Y9aPg on line 6 H: 1 E: 0 User 'user3' has password 'phplol'? no Warning: A non-numeric value encountered in /in/Y9aPg on line 6 H: 0 E: 0 User 'user3' has password 'FN4A_zKEe]33p!'? yes Notice: A non well formed numeric value encountered in /in/Y9aPg on line 6 H: 1 E: 251308 User 'user4' has password 'phplol'? no Notice: A non well formed numeric value encountered in /in/Y9aPg on line 6 H: 251308 E: 251308 User 'user4' has password 'xXgjan3a58qzX3'? yes Now let's get funky! Warning: A non-numeric value encountered in /in/Y9aPg on line 6 H: 0 E: 0 User 'user3' has password 'password1'? yes Warning: A non-numeric value encountered in /in/Y9aPg on line 6 H: 0 E: 0 User 'user3' has password 'fN.4A_zKEe]33p!'? yes Warning: A non-numeric value encountered in /in/Y9aPg on line 6 H: 0 E: 0 User 'user3' has password 'fN.4A_zKEe]33p!'? yes
Output for 5.4.2 - 7.0.20
H: 1 E: 0 User 'user1' has password 'phplol'? no H: 0 E: 0 User 'user1' has password 'password1'? yes H: 1 E: 6 User 'user2' has password 'phplol'? no H: 6 E: 6 User 'user2' has password 'hunter2'? yes H: 1 E: 0 User 'user3' has password 'phplol'? no H: 0 E: 0 User 'user3' has password 'FN4A_zKEe]33p!'? yes H: 1 E: 251308 User 'user4' has password 'phplol'? no H: 251308 E: 251308 User 'user4' has password 'xXgjan3a58qzX3'? yes Now let's get funky! H: 0 E: 0 User 'user3' has password 'password1'? yes H: 0 E: 0 User 'user3' has password 'fN.4A_zKEe]33p!'? yes H: 0 E: 0 User 'user3' has password 'fN.4A_zKEe]33p!'? yes
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/Y9aPg on line 9
Process exited with code 255.