3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php // generate random string given length function genString($length = 22){ $s = ''; $chars = array_merge(range('A','Z'), range('a','z'), range(0,9)); while($length > 0){ $randKey = array_rand($chars, 1); $s .= $chars[$randKey]; $length--; } return $s; } $digit = (PHP_VERSION_ID >= 50307) ? 'y' : 'a'; $salt = '$2'.$digit.'$10$'.genString(); //echo 'Salt: '.$salt.'<br>'; $password = 'password'; $hash = crypt($password, $salt); echo 'Strlen: '.strlen($hash).' ------ '; if (crypt($password, $hash) == $hash) { echo "Password verified!"; } ?>
Output for 5.3.0 - 5.6.21, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Strlen: 60 ------ Password verified!
Output for 5.2.7 - 5.2.17

Process exited with code 139.
Output for 4.3.0 - 5.2.6
Notice: Use of undefined constant PHP_VERSION_ID - assumed 'PHP_VERSION_ID' in /in/o1DWo on line 15
Process exited with code 139.