3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function getShortUrl(int $id) { $chars = "123456789bcdfghjkmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ"; $length = strlen($chars); $id = intval($id); if ($id < 1) { return 0; } $code = ""; while ($id > $length - 1) { $fmod =intval(fmod($id, $length)); $code =$chars[$fmod].$code; $id = floor($id / $length); } $code = $chars[intval($id)] . $code; return $code; } $short_url=getShortUrl(14992139347739999999999); echo "sinadme.com/".$short_url;
based on 2L8TS
Output for 7.3.0 - 7.3.1
Fatal error: Uncaught TypeError: Argument 1 passed to getShortUrl() must be of the type int, float given, called in /in/ftjTp on line 20 and defined in /in/ftjTp:2 Stack trace: #0 /in/ftjTp(20): getShortUrl(1.499213934774E+22) #1 {main} thrown in /in/ftjTp on line 2
Process exited with code 255.
Output for 7.0.0 - 7.2.13
Fatal error: Uncaught TypeError: Argument 1 passed to getShortUrl() must be of the type integer, float given, called in /in/ftjTp on line 20 and defined in /in/ftjTp:2 Stack trace: #0 /in/ftjTp(20): getShortUrl(1.499213934774E+22) #1 {main} thrown in /in/ftjTp on line 2
Process exited with code 255.
Output for hhvm-3.15.4
Fatal error: Uncaught TypeError: Argument 1 passed to getShortUrl() must be an instance of int, double given in /in/ftjTp:19 Stack trace: #0 /in/ftjTp(20): getShortUrl() #1 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.38
Catchable fatal error: Argument 1 passed to getShortUrl() must be an instance of int, double given, called in /in/ftjTp on line 20 and defined in /in/ftjTp on line 2
Process exited with code 255.