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(123); echo "sinadme.com/".$short_url;
based on GZpNP
Output for hhvm-3.15.4, 7.0.0 - 7.2.6
sinadme.com/3t
Output for 5.6.0 - 5.6.30
Catchable fatal error: Argument 1 passed to getShortUrl() must be an instance of int, integer given, called in /in/O2Ou3 on line 20 and defined in /in/O2Ou3 on line 2
Process exited with code 255.