I want to echo binary data to be parsed by my http client. I'm working with HTTP GET and i have tried this:
<?php
if (isset($_GET['mac'])) {
if (isset($_GET['f'])) {
switch ($_GET['f']){
case 'get_maclist':
$binarydata = pack("C*", 0x00, 0x00,0x10, 0x2C, 0x1B, 0x16, 0x4C, 0xDF, 0xCB, 0x00, 0x01);
$header="Content-Disposition: attachment; filename=test.bin;";
header($header);
header("Content-Transfer-Encoding: binary");
echo $binarydata;
url i call:http://MyIP/test.php?mac=ABC&f=get_maclist
but what i receive in the file is different when looking at the binary file with a hex editor. How do I get this done correctly?
Thanks
I figured it out. The problem was at a different spot in my code, simply because I forgot a break; in a switch() and it would load different data into the binary file than expected ...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.