3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = 0x40; $b = ~$a; // flip bits, i.e. 2s complement so -$a and then minus 1 var_dump("var_dump: $b"); // -65 printf("\nprintf: %d\n\n", $b); var_dump( base_convert($b, 10, 2) ); // 65 // **************************// // should be: printf("\nprintf: %b\n\n", $b); echo hex2bin(0x40);
Output for 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.6
string(13) "var_dump: -65" printf: -65 Deprecated: Invalid characters passed for attempted conversion, these have been ignored in /in/UjRGc on line 7 string(7) "1000001" printf: 1111111111111111111111111111111111111111111111111111111110111111 d
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.38, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
string(13) "var_dump: -65" printf: -65 string(7) "1000001" printf: 1111111111111111111111111111111111111111111111111111111110111111 d

preferences:
267.11 ms | 403 KiB | 323 Q