So I'm making this script that needs to get the integer from the & operator of two numers in PHP. So far I have managed it to work but with small numbers (<512). When I try to do do for example:
echo 65535 $ 2048;
I get a result of 0, when it's supposed to be 2048. Any ideas why I am getting this result or how can I get the desired result?. Thank you In advance
I'm using PHP 5.5 and Ubuntu.
问问题
51 次
2 回答
1
$
不是and
运营商,&
是。
如果你试试:
echo 65535 & 2048;
你应该会2048
好起来的,就像我刚刚在http://sandbox.onlinephpfunctions.com/上所做的那样。
于 2014-08-28T04:44:29.737 回答
0
当您尝试运行它时:
echo 65535 $ 2048;
你会得到这个错误:
syntax error, unexpected '$', expecting ',' or ';'
对于我的案例代码:
echo 65535 & 2048;
输出2048
注意:你有错字,应该用 & 代替 $。因为 $ 不是和运算符,而是 & 是。
演示
于 2014-08-28T04:43:29.873 回答