title: How to deal with binary data in php (not binary string)?
body: <p>I wrote a C++ program which send POST data to php. My data is 123456 in binary, which is 0x0001e240.</p>
  
  <p>My php file reads like</p>
  
  <pre><code>$f=fopen("php://input", "r");
  if (!$f) die ("cannot open");
  $data = fread($f, 4);
  echo $data;
  </code></pre>
  
  <p>In my receiving program (in C++), I can see the echoed data is exactly 0x0001e240, so I believe php did accept a pure binary thing and saved into $data.</p>
  
  <p>However, I want to get 123456 in php. I tried functions like bindec, hexdec, and so on but none of them works. How can I get the number from $data.</p>
  
  <p>Also, do I need to care about endians in php? I am working locally now with windows environment but I will finally put my codes onto cloud.</p>
  
  <p>Edit</p>
  
  <pre><code>$f=fopen("test.bin", "rb");
  if (!$f) die ("cannot open");
  $data = fread($f, 4);
  echo $data;
  </code></pre>
  
  <p>where test.bin is a bin file which contains 0x0001e240. It seems that I got a string in $data which is composited with ASCII of 0x00, 0x01, 0xe2, and 0x40. How can I make them into a number value?</p>