通过PHP实现URL转发

使用函数file_get_contents()

1
2
3
<?php
echo file_get_contents('https://blog.ssss.fun');
?>

使用PHP扩展CURL

1
2
3
4
5
6
7
8
9
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://blog.ssss.fun');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
$contents = curl_exec($ch);
curl_close($ch);
echo $contents;
?>