在PHP中,输出为字节数组和流.哪一个更好


In PHP, output as byte array and stream. Which one is better?

我需要编写一个php web服务来将文件输出到Windows客户端应用程序。我有两个选择字节数组和流。哪一个在PHP中更好、更容易实现?

谢谢你的帮助。

不如。。。。

$file = 'some_file.exe';
$_size = filesize($_file);
header('Content-Type: binary/octet-stream');
header('Content-Length: '.$_size);
header('Content-Disposition: attachment; filename="' . basename($file) . '"; size=" . $_size);
@readfile($file);

注意:请参阅有关二进制文件的一些问题的评论。