3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $code = ""; $namespace = __NAMESPACE__; foreach (array(10, 11, 12, 14, 20, 21, 22, 26, 27, 31) as $n) { $val = ~((~0) << $n); $code .= "namespace $namespace { const MASK$n = $val; }\n"; } foreach (array(16, 31, 32) as $n) { $val = pow(2, $n); $code .= "namespace $namespace { const TWO_TO_THE_$n = $val; }\n"; } echo $code; $val = MASK31 | (MASK31 << 1); echo "namespace $namespace { const MASK32 = $val; }";
Output for 7.2.0
namespace { const MASK10 = 1023; } namespace { const MASK11 = 2047; } namespace { const MASK12 = 4095; } namespace { const MASK14 = 16383; } namespace { const MASK20 = 1048575; } namespace { const MASK21 = 2097151; } namespace { const MASK22 = 4194303; } namespace { const MASK26 = 67108863; } namespace { const MASK27 = 134217727; } namespace { const MASK31 = 2147483647; } namespace { const TWO_TO_THE_16 = 65536; } namespace { const TWO_TO_THE_31 = 2147483648; } namespace { const TWO_TO_THE_32 = 4294967296; } Warning: Use of undefined constant MASK31 - assumed 'MASK31' (this will throw an Error in a future version of PHP) in /in/Z680M on line 18 Warning: Use of undefined constant MASK31 - assumed 'MASK31' (this will throw an Error in a future version of PHP) in /in/Z680M on line 18 Warning: A non-numeric value encountered in /in/Z680M on line 18 Warning: A non-numeric value encountered in /in/Z680M on line 18 namespace { const MASK32 = 0; }
Output for 7.1.0 - 7.1.10
namespace { const MASK10 = 1023; } namespace { const MASK11 = 2047; } namespace { const MASK12 = 4095; } namespace { const MASK14 = 16383; } namespace { const MASK20 = 1048575; } namespace { const MASK21 = 2097151; } namespace { const MASK22 = 4194303; } namespace { const MASK26 = 67108863; } namespace { const MASK27 = 134217727; } namespace { const MASK31 = 2147483647; } namespace { const TWO_TO_THE_16 = 65536; } namespace { const TWO_TO_THE_31 = 2147483648; } namespace { const TWO_TO_THE_32 = 4294967296; } Notice: Use of undefined constant MASK31 - assumed 'MASK31' in /in/Z680M on line 18 Notice: Use of undefined constant MASK31 - assumed 'MASK31' in /in/Z680M on line 18 Warning: A non-numeric value encountered in /in/Z680M on line 18 Warning: A non-numeric value encountered in /in/Z680M on line 18 namespace { const MASK32 = 0; }
Output for 5.3.17 - 7.0.20
namespace { const MASK10 = 1023; } namespace { const MASK11 = 2047; } namespace { const MASK12 = 4095; } namespace { const MASK14 = 16383; } namespace { const MASK20 = 1048575; } namespace { const MASK21 = 2097151; } namespace { const MASK22 = 4194303; } namespace { const MASK26 = 67108863; } namespace { const MASK27 = 134217727; } namespace { const MASK31 = 2147483647; } namespace { const TWO_TO_THE_16 = 65536; } namespace { const TWO_TO_THE_31 = 2147483648; } namespace { const TWO_TO_THE_32 = 4294967296; } Notice: Use of undefined constant MASK31 - assumed 'MASK31' in /in/Z680M on line 18 Notice: Use of undefined constant MASK31 - assumed 'MASK31' in /in/Z680M on line 18 namespace { const MASK32 = 0; }