Tom*_*Tom 0 php header file-get-contents
我需要更改PHP在使用file_get_contents()请求文件时发送的标头.这是可能的还是我必须使用CURL?
您可以将file_get_contents()与stream_context_create()结合使用
例如:
<?php
$context = stream_context_create(array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n" .
"Cookie: foo=bar\r\n"
)
));
$out = file_get_contents($filename, false, $context);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
237 次 |
| 最近记录: |