Seb*_*bas 16 php security .htaccess
我需要访问一个受常规.htaccess文件保护的外部.php页面(Auth type Basic,htpasswords等...).
我想通过请求发送所需的用户和密码.可能吗?如果可能的话,我想避免cURL和所有pecl_http依赖的功能......
bis*_*hop 30
副手,我相信你可以使用上下文来做到这一点:
$context = stream_context_create(array (
'http' => array (
'header' => 'Authorization: Basic ' . base64_encode("$username:$password")
)
));
$data = file_get_contents($url, false, $context);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13849 次 |
| 最近记录: |