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; } $prefix = (PHP_VERSION_ID >= 50307) ? '$2y$' : '$2a$'; $salt = $prefix.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 7.0.0 - 7.1.0
Strlen: 2 ------
Output for 5.3.0 - 5.6.28
Strlen: 13 ------ 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/eHWrC on line 15
Process exited with code 139.