I'm trying to send the binary representation of data through a PHP socket.
So if the number was 15, socket_write would send 00001111 as binary representation for 15.
How should I do this?
To generate a binary representation from arbitrary data use the pack() function.
Example:
$data = pack("v", 15); // "i" is unsigned little endian integer
socket_write($socket, $data);
See the manual page for more information on the various formats. There's also unpack() for the reverse functionality.
socket_write($fp, 15)it will be same assocket_write($fp, "15"), I.E. send the bytes0x31 0x35whereas as far as I can see he wants to send one byte0x0F