PHP Mathematical function acts like (AND) ...




what is the Mathematical function in PHP which acts like (AND) to adding two HEX numbers ?

Like 'A37C34B6' AND 'C342A123' ... ?

You're looking for bitwise AND. Remember, in PHP hex numbers are written in C-style format: 0xA37C34B6, 0xC342A123, not between quotes.
Well I try to use this code :

  $n1 = '0x'.'A37C34B6';
  $n2 = '0x'.'C342A123';

  $resultAND = $n1 & $n2;

  echo ($resultAND);

It workds , but dont know whats the answer !!!
The answer looks like this :


whish is include some strange characters !
am I doing the right code ? or should I change some ?

Thanx for help
I also try to use this model for ADDING two HEXA numbers :

      $n1 = dechex(14); // (e) in HEXA
      $n2 = dechex(1); // (1) in HEXA
      echo ($n1) . "<br>";
      echo ($n2) . "<br>";
      $resultAND = dechex ($n1 + $n2);
      echo ($resultAND);

in mathematics and HEXA we have like :
  e + 1 = f

but my answer is (1) !!!!!!!!!!!!
Why ? What I am doing wrong ?
Well , thanx , I think I can sort this out
but what about [AND] ?
How can I do this with hexa in PHP ?
Could you please give me an example instead of linking me to other sites ?
Cause I myself can read them all ! But couldnt understand them , thats why i am using this forum , otherwise there is no need to use this forum anyway !
think we have two hex numbers like this :

$n1 = 0xAB4500FF
$n2 = 0x000FF456

Now please show me how do you [AND] these numbers using Bitwise AND!
I appreciate it....
$n1 = 0xAB4500FF;
$n2 = 0x000FF456;
$na_and_n2 = $n1 & $n2;

That's exactly like it says on the linked pages.
swirlee .......
Thanx a million ,
I was very confused with this operation
but this one is neat , it works and works perfect.
I also appreciate to gesf who gave me lot help about it.
Thanx a million to both of you