3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = '0x8000000'; $data = substr($data, 2); //remove the 0x prefix from the string $data = str_replace(' ', '', $data); //remove the spaces from the string //$data is now '11210031' $number = hexdec($data); //convert the hexadecimal number to an integer //$number is now 0x11210031 (hexadecimal) = 287375409 (decimal) $nibble1 = ($number >> 28) & 0xF; //shift the number right by 28 bits (each nibble is 4 bits) and select only the last 4 bits (0xF selects all bits in the last nibble) echo "the product number is $nibble1\n"; $nibble2 = ($number >> 24) & 0xF; if ($nibble2 == 1) { echo "this is a new product\n"; } else if ($nibble2 == 2) { echo "this is a used product\n"; }
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
the product number is 0
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 the product number is 0

preferences:
148.44 ms | 402 KiB | 154 Q