-4

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.

2 Answers2

1

$ is not the and operator, & is.

If you try:

echo 65535 & 2048;

you should get 2048 just fine, as I just did on http://sandbox.onlinephpfunctions.com/.

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
0

When you try to run this:

echo 65535 $ 2048;

You will get this error:

syntax error, unexpected '$', expecting ',' or ';'

For my case code:

echo 65535 & 2048;

Giving output 2048

Note: You have typo there should be & inplace of $. because $ is not and operator but & is.

DEMO

Community
  • 1
  • 1
Manwal
  • 23,450
  • 12
  • 63
  • 93