/**
* @return 获取bin文件
*/
public function getBin(){
$sql = Db::connect("***")->table('***')->order('id','desc')->find();
if ($sql){
//打开文件转化为16进制
$url = dirname(dirname(dirname(__DIR__)))."/public/Bin".$sql['url'];
$file_pointer = fopen($url, "rb");
$file_read = fread($file_pointer, filesize($url));
//关闭打开的文件
fclose($file_pointer);
$data = bin2hex($file_read);
$sendStrArray = str_split(str_replace(' ', '', $data), 2); // 将16进制数据转换成两个一组的数组
$ar = '';
for ($j = 0; $j < count($sendStrArray); $j++) {
if ($j == 0){
$ar = $sendStrArray[$j];
}else{
$ar .= $sendStrArray[$j];
}
}
return hex2bin($ar);
}else{
return;
}
}