编辑这篇文章,我认为我的问题被解释错了:
我希望我的php页面可以从任何页面下载HTML代码,我实际上可以期待一个," http://www.lolnexus.com/ "并且我制作了这段代码
$nexus= file_get_contents('http://www.lolnexus.com/');
$myFile = "nexus.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $nexus);
fclose($fh);
Run Code Online (Sandbox Code Playgroud)
结果是:这个
<html><head><title>Object moved</title></head><body>
Run Code Online (Sandbox Code Playgroud)
如果我将我的网址更改为其他网页,它工作正常.....
谢谢阅读
您必须使用该选项 CURLOPT_FOLLOWLOCATION
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
Run Code Online (Sandbox Code Playgroud)
这让我们卷曲从Web服务器发出的任何重定向.