0

I'm using PHP 7.2.8

I executed below code :

<?php
  phpinfo(2 | 8); //Bitwise OR operator is used
?>

Above code worked fine and give me the expected result.

Then I tried to pass the numerical constants bitwise values as arguments i.e. binary equivalents of numbers 2 and 8 as arguments. Please see the below code :

<?php
  phpinfo(00000010 | 1000000); //Bitwise OR operator is used
?>

I got unexpected output of above code(i.e. the second one where bitwise values of numerical constants are passed).

Why so?

Please refer This Link for the information of description on arguments to be passed to the phpinfo() function and the meaning of each and every numerical constants to be passed.

Please let me know where I'm making a mistake? I'm just trying to execute the code as described in the manual text.

Thank You.

4

1 回答 1

5

要在 PHP 中用二进制表示数字,您必须使用前缀0b(例如,0b00000010)。

如果没有该前缀,这些数字会以您不希望的方式进行解释。00000010被解释为 8 的八进制表示,1000000并被读取为十进制的一百万。

于 2018-08-21T18:48:51.900 回答