3v4l.org

run code in 300+ PHP versions simultaneously
<?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", "88"); checkLogIn("user3", "php pls");
Output for 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
Fatal error: Uncaught TypeError: Unsupported operand types: string + int in /in/PIKSR:6 Stack trace: #0 /in/PIKSR(10): saltedHash('password1') #1 {main} thrown in /in/PIKSR on line 6
Process exited with code 255.
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 Fatal error: Uncaught TypeError: Unsupported operand types: string + int in /in/PIKSR:6 Stack trace: #0 /in/PIKSR(10): saltedHash('password1') #1 {main} thrown in /in/PIKSR on line 6
Process exited with code 255.
Output for 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.31, 7.4.0 - 7.4.33
Warning: A non-numeric value encountered in /in/PIKSR on line 6 Notice: A non well formed numeric value encountered in /in/PIKSR on line 6 Warning: A non-numeric value encountered in /in/PIKSR on line 6 Notice: A non well formed numeric value encountered in /in/PIKSR on line 6 Notice: A non well formed numeric value encountered in /in/PIKSR on line 6 H: 1 E: 0 User 'user1' has password 'phplol'? no Warning: A non-numeric value encountered in /in/PIKSR on line 6 H: 0 E: 0 User 'user1' has password 'password1'? yes Notice: A non well formed numeric value encountered in /in/PIKSR on line 6 H: 1 E: 6 User 'user2' has password 'phplol'? no Notice: A non well formed numeric value encountered in /in/PIKSR on line 6 H: 6 E: 6 User 'user2' has password 'hunter2'? yes Notice: A non well formed numeric value encountered in /in/PIKSR on line 6 H: 1 E: 0 User 'user3' has password 'phplol'? no Warning: A non-numeric value encountered in /in/PIKSR 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/PIKSR on line 6 H: 1 E: 251308 User 'user4' has password 'phplol'? no Notice: A non well formed numeric value encountered in /in/PIKSR 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/PIKSR on line 6 H: 0 E: 0 User 'user3' has password 'password1'? yes Warning: A non-numeric value encountered in /in/PIKSR on line 6 H: 0 E: 0 User 'user3' has password 'fN.4A_zKEe]33p!'? yes Warning: A non-numeric value encountered in /in/PIKSR on line 6 H: 0 E: 0 User 'user3' has password '88'? yes Warning: A non-numeric value encountered in /in/PIKSR on line 6 H: 0 E: 0 User 'user3' has password 'php pls'? yes
Output for 7.3.32 - 7.3.33
Warning: A non-numeric value encountered in /in/PIKSR on line 6 Warning: A non-numeric value encountered in /in/PIKSR on line 6 H: 1 E: 0 User 'user1' has password 'phplol'? no Warning: A non-numeric value encountered in /in/PIKSR on line 6 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 Warning: A non-numeric value encountered in /in/PIKSR on line 6 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! Warning: A non-numeric value encountered in /in/PIKSR on line 6 H: 0 E: 0 User 'user3' has password 'password1'? yes Warning: A non-numeric value encountered in /in/PIKSR on line 6 H: 0 E: 0 User 'user3' has password 'fN.4A_zKEe]33p!'? yes Warning: A non-numeric value encountered in /in/PIKSR on line 6 H: 0 E: 0 User 'user3' has password '88'? yes Warning: A non-numeric value encountered in /in/PIKSR on line 6 H: 0 E: 0 User 'user3' has password 'php pls'? yes
Output for 5.4.2 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28, 7.0.0 - 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 '88'? yes H: 0 E: 0 User 'user3' has password 'php pls'? yes

preferences:
212.19 ms | 403 KiB | 226 Q