3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function gdr_encode($val) { $bin = ''; while ($val > 0) { $bin .= chr($val & 0xFF); $val >>= 8; } return str_replace(array('/', '='), array('_', ''), base64_encode($bin)); } function gdr_decode($str) { $bin = base64_decode(str_replace('_', '/', $str)); $val = 0; for ($i=strlen($bin)-1; $i>=0; $i--) { $val |= ord($bin[$i]) << $i*8; } return $val; } // seed rng for consistent values if (phpversion() < '5.2.1') { die('old rng'); } mt_srand(42); for ($i=0; $i<63; $i++) { $val = 1<<$i; $val += mt_rand(0, $val/2); $enc = gdr_encode($val); $dec = gdr_decode($enc); if ($val === $dec) { echo "$enc $val\n"; } else { echo "$enc $valĀ ERROR: gdr_decode($enc) == $dec\n"; } }
based on nRMPD
Output for 7.1.0
AQ 1 Aw 3 BQ 5 DA 12 EA 16 Jg 38 WQ 89 uw 187 QAE 320 EQI 529 KAQ 1064 cgg 2162 tBU 5556 Ky0 11563 oUo 19105 wpc 38850 oXgB 96417 1cYC 181973 9uMF 386038 2nYI 554714 7QUV 1377773 Tfwg 2161741 P_tL 4979519 dOaU 9758324 QfQaAQ 18543681 rfxEAg 38075565 CttbBA 73128714 gQkzCA 137562497 uhSMFg 378279098 rJMBLg 771855276 E5nzTg 1324587283 nkQTng 2652062878 y9HiTQE 5601677771 3SLB6QI 12511683293 bWasbQQ 19019884141 WiMUSQg 35585794906 _2_XixI 79655563263 CgpQHS4 198060280330 nGtqSl8 409270381468 pcPkWbs 804667048869 79JJdA4B 1161592165103 sxjqyL0C 3014142859443 7arOMr0F 6310159362797 9WOMg2sL 12556396422133 nwSJl_MU 23036451947679 prTcC_gl 41747281130662 Ci6Bm+RN 85644256816650 cr+kK4ai 178697141534578 _1GmEEhrAQ 399432237863423 Hibq8hFVAg 656485531657758 oTAz91giBA 1163665406636193 5fzyzg2oCw 3281002003889381 sx77TfmnEg 5251238777790131 8wkBGVldJg 10798686367975923 e+Mpr4HbWw 25855572916691835 eNStcFvYsw 50621908075271288 aeQ9H7tbagE 101994800810419305 YOnDfqu9KAI 155582731408107872 RK_NCAdDTAU 381753765911179076 wjjJ6CKgYQg 603939896839190722 l2c_QlCMHBQ 1449187456443180951 ZQ+bqTEGpy4 3361662457224040293 +0vMT4NdX0E 4710586553813715963
Output for 5.2.1 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.0.14
AQ 1 Aw 3 Bg 6 DA 12 Eg 18 Iw 35 TQ 77 mQ 153 FAE 276 cgI 626 swU 1459 nAs 2972 dxA 4215 sCg 10416 ZUQ 17509 _6o 43775 8UwB 85233 kyQC 140435 p5cE 300967 g5oK 694915 KCoQ 1059368 cg4v 3083890 gQlf 6228353 OzWu 11416891 j8YVAQ 18204303 _kTwAg 49300734 trdsBA 74233782 jpP6Cw 200971150 pmB0EQ 292839590 lWcJIA 537487253 InPeRQ 1172206370 kyshmA 2552310675 5WjxJgE 4948322533 1KcCYgI 10234275796 KOCsDAU 21687492648 8GM8Bwg 34481136624 UJefdBM 83560994640 gLV2XiA 139023791488 AMa_UUk 314904135168 gHbolaE 694004774528 AGvHGjEB 1310414301952 AP5JXWYC 2638675049984 AFC9a0cE 4704796758016 AEi0ltUL 13011984336896 ALC58KIV 23789567586304 AGAF_n0g 35725504765952 AEAkwWtU 92821778612224 AIB4Q0Cx 194889567993856 AABegGA6AQ 345661121626112 AABQEabpAg 819849417719808 AACEQC1vBA 1248140053446656 AADwLjp5Cg 2948040569651200 AACQke6YEQ 4953225015853056 AACgdpAeJg 10729654929326080 AABAm2amTw 22419482781679616 AACAPEHtvg 53741110018703360 AAAA6cifNAE 86869978078248960 AAAA+MV9dwI 177748999527202816 AAAABFnIFwQ 294924585260810240 AAAAkDeUcAs 824321698168832000 AAAAkHlA3BQ 1503147266486042624 AAAAoIb0CyU 2669496063194300416 AAAAgALvdEU 5004887879931920384
Output for 4.3.0 - 5.2.0
old rng