How to speed up file_get_contents?

前端 未结 3 1236
暗喜
暗喜 2021-02-07 19:44

Here\'s my code:

$language = $_GET[\'soundtype\'];
$word = $_GET[\'sound\'];
$word = urlencode($word);
if ($language == \'english\') {
    $url = \"

        
3条回答
  •  说谎
    说谎 (楼主)
    2021-02-07 20:16

    As explained by @MrCode, first downloading the file to your server, then passing it on to the client will of course incur a doubled download time. If you want to pass the file on to the client directly, use readfile.

    Alternatively, think about if you can't simply redirect the client to the file URL using a header("Location: $url") so the client can get the file directly from the source.

提交回复
热议问题