php怎么打开网页

发布日期:2023-10-28 07:29:32

以使用PHP中的curl函数或file_get_contents函数打开网页。例如,使用curl函数可以这样做:


$url = \'http://www.example.com\';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
echo $output;

或者,使用file_get_contents函数可以这样做:


$url = \'http://www.example.com\';
$output = file_get_contents($url);
echo $output;

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

近期评论

没有评论可显示。