cod*_*ict 31
您只需使用file_get_contents即可.它更容易.
echo file_get_contents('http://www.google.com');
Run Code Online (Sandbox Code Playgroud)
如果你必须使用wget,你可以尝试以下方法:
$url = 'http://www.google.com';
$outputfile = "dl.html";
$cmd = "wget -q \"$url\" -O $outputfile";
exec($cmd);
echo file_get_contents($outputfile);
Run Code Online (Sandbox Code Playgroud)
Chr*_*rke 11
该exec函数可用于运行wget.我从来没有使用过wget来进行简单的文件下载,但你会使用你给wget的任何参数来输出文件内容.exec的第二个参数/参数将是一个数组,并且该数组将与wget的输出一行一行填充.
所以你会有类似的东西:
<?php
exec('wget http://google.com/index.html -whateverargumentisusedforoutput', $array);
echo implode('<br />', $array);
?>
Run Code Online (Sandbox Code Playgroud)
exec的手册页可能更好地解释了这个:http: //php.net/manual/en/function.exec.php