3v4l.org

run code in 300+ PHP versions simultaneously
<?php function dechex_size($val, $size) { if ($size < 1) { error_log("Invalid value for $size"); return false; } $bits = $size << 2; if ($bits > log(PHP_INT_MAX, 2)) { return dechex($val); } $mask = 0; for ($i = 0; $i < $size; ++$i) { $mask = ($mask << 4) | 0xF; } $val &= $mask; return sprintf("%x", $val); } echo dechex_size(15,4), "\n"; // gives 000f echo dechex_size(-1,16), "\n"; // gives ffffffffffffffff echo dechex_size(-1,2), "\n"; // gives ff echo dechex_size(1025,2), "\n"; // gives ? (either 401, 01, ff, or false)
Output for git.master, git.master_jit, rfc.property-hooks
f ffffffffffffffff ff 1

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:
46.37 ms | 401 KiB | 8 Q