我是php新手,我希望通过使用php curl获取网页html ...我没有得到输出,我只是得到一个白页。 有人可以帮忙吗?
<?php
$url=$_POST['txturl'];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$output = curl_exec($ch);
echo $output;
curl_close($ch);
?>
答案 0 :(得分:4)
您不需要发送两次网址
<?php
$url=$_POST['txturl'];
$ch = curl_init();//I have removed it from here
curl_setopt($ch, CURLOPT_URL,$url);// This will do
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$output = curl_exec($ch);
echo $output;
curl_close($ch);
?>
<?php
echo function_exists('curl_version')?'Yes':'No';
?>