给字符串赋予isset值

时间:2015-11-23 08:09:32

标签: php

我正在努力使$url字符串在设置example.com/?url=MyExample.com时显示网址中的内容。

<?php
$ch = curl_init($url);
$fp = fopen("s.txt", "w");

curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);

$output = curl_exec($ch);
curl_close($ch);
fclose($fp);
?>

提前感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

为什么这么复杂呢?

if(isset($_GET["url"]))                   //  you can add check to validate url
$content=file_get_contents($_GET["url"]);

现在您可以像

一样显示它
echo $content;

或保存在您的文件中

file_put_contents("s.txt",$content);  // you can check whether this failed
相关问题