在使用file_get_contents函数请求页面时,我们可以配置php.ini文件来发送user agent信息,那如何设置HTTP头信息呢?具体实现请看下面源码:
<?php
// Create a stream
$opts = array(
\'http\'=>array(
\'method\'=>\"GET\",
\'header\'=>\"Accept-language: en\\r\\n\" .
\"Cookie: foo=bar\\r\\n\"
)
);
$context = stream_context_create($opts);
/* http://www.manongjc.com/article/1425.html */
// Open the file using the HTTP headers set above
$file = file_get_contents(\'http://www.example.com/\', false, $context);
?> 继续阅读与本文标签相同的文章
-
梦幻西游:又一服战大佬萌生退意,大量装备均已上架,服战是凄凉
2026-05-14栏目: 教程
-
00后手机里最“不能卸载”的3款软件,QQ不算啥,动第2个直接绝交
2026-05-14栏目: 教程
-
“钞”能力:美一牙医掷百万购入任天堂老游戏创游戏单笔交易记录
2026-05-14栏目: 教程
-
美国公司想用5G技术 华为:正就授权进行初期谈判
2026-05-14栏目: 教程
-
微软修复Windows 10 Build 18999/19002关机卡死问题
2026-05-14栏目: 教程
