3v4l.org

run code in 300+ PHP versions simultaneously
<?php function pack_encode($val) { $str = ''; while ($val > 0) { $str .= chr($val & 0xFF); $val = $val >> 8; } // "/" json-encodes poorly and "=" is padding return str_replace( array('/', '='), array('_', ''), base64_encode($str) ); } function pack_decode($bin) { $str = base64_decode(str_replace('_', '/', $bin)); $val = 0; for ($i=0; $i<strlen($str); $i++) { $val |= (ord($str[$i]) << ($i * 8)); } return $val; } for ($i=0; $i<32; $i++) { $val = 1<<$i; $enc = pack_encode($val); $dec = pack_decode($enc); echo "$val => $enc => $dec\n"; } $max = 1<<32; $n = 32; $step = intval($max/$n); for ($i=0; $i<=$n; $i++) { $val = $i*$step; $enc = pack_encode($val); $dec = pack_decode($val); echo "$enc $dec $val\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
1 => AQ => 1 2 => Ag => 2 4 => BA => 4 8 => CA => 8 16 => EA => 16 32 => IA => 32 64 => QA => 64 128 => gA => 128 256 => AAE => 256 512 => AAI => 512 1024 => AAQ => 1024 2048 => AAg => 2048 4096 => ABA => 4096 8192 => ACA => 8192 16384 => AEA => 16384 32768 => AIA => 32768 65536 => AAAB => 65536 131072 => AAAC => 131072 262144 => AAAE => 262144 524288 => AAAI => 524288 1048576 => AAAQ => 1048576 2097152 => AAAg => 2097152 4194304 => AABA => 4194304 8388608 => AACA => 8388608 16777216 => AAAAAQ => 16777216 33554432 => AAAAAg => 33554432 67108864 => AAAABA => 67108864 134217728 => AAAACA => 134217728 268435456 => AAAAEA => 268435456 536870912 => AAAAIA => 536870912 1073741824 => AAAAQA => 1073741824 2147483648 => AAAAgA => 2147483648 0 0 AAAACA 271299514891991 134217728 AAAAEA 63354512650203 268435456 AAAAGA 136880200502755 402653184 AAAAIA 128986184974055 536870912 AAAAKA 203198987288043 671088640 AAAAMA 275624484097779 805306368 AAAAOA 67679481855991 939524096 AAAAQA 61779968957828823 1073741824 AAAASA 65154447574789591 1207959552 AAAAUA 68669718855581399 1342177280 AAAAWA 59519720675249879 1476395008 AAAAYA 62974931863121367 1610612736 AAAAaA 66208733129653975 1744830464 AAAAcA 69583211100753623 1879048192 AAAAeA 61781209859444187 2013265920 AAAAgA 64170581900877531 2147483648 AAAAiA 67403696043290587 2281701376 AAAAkA 59520275120229851 2415919104 AAAAmA 62976172773121755 2550136832 AAAAoA 66209974039654363 2684354560 AAAAqA 68599346089479643 2818572288 AAAAsA 60575247802752731 2952790016 AAAAuA 64171135683219423 3087007744 AAAAwA 67404936961682911 3221225472 AAAAyA 59662309353160415 3355443200 AAAA0A 61710837084950495 3489660928 AAAA2A 65085315722227167 3623878656 AAAA4A 68600586999480031 3758096384 AAAA6A 60575801585094623 3892314112 AAAA8A 64031699913821667 4026531840 AAAA+A 66280278635863779 4160749568 AAAAAAE 69795550584139747 4294967296

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
49.4 ms | 405 KiB | 8 Q