我有一个用于为某个网页生成iframe的代码,我需要在下面显示该icframe的源代码。您还可以看到我想要在www.pluspon.com/get3.php做:类似字符串的源代码
<?php
error_reporting(E_ALL^E_NOTICE);
$url = $_GET['url'];
if(! empty($url))
{
$data = file_get_contents($url);
$data = str_replace('<head>', '<head><base href="'.$url.'" /></base>', $data);
$data = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $data);
$data = preg_replace('#<iframe(.*?)></iframe>#is', '', $data);
$data .=
'
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$("div").each(function(i){
if($(this).css("position") == "fixed") $(this).css("display", "none");
});
</script>
'
;
die($data);
}
?>
<iframe id="iframe" src="?url=http://kupime.com"></iframe></div>
现在我需要显示这个iframe的源代码,但我尝试:
<?php echo htmlspecialchars(file_get_contents($_GET['url'])); ?>
但doen't工作。为什么?你能告诉我有人吗?
更新:这里是全码:
<?php
error_reporting(E_ALL^E_NOTICE);
$url = $_GET['url'];
if(! empty($url))
{
$data = file_get_contents($url);
$data = str_replace('<head>', '<head><base href="'.$url.'" /></base>', $data);
$data = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $data);
$data = preg_replace('#<iframe(.*?)></iframe>#is', '', $data);
$data .=
'
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$("div").each(function(i){
if($(this).css("position") == "fixed") $(this).css("display", "none");
});
</script>
'
;
die($data);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="author" content="Webarto" />
<title>AdriaMart</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<style type="text/css">
<!--
iframe{width:100%;height:400px;}
-->
</style>
</head>
<body>
<iframe id="iframe" src="?url=http://kupime.com"></iframe>
</body>
</html>
定义“不工作”。 – 2011-12-20 16:20:24
请参阅pluspon.com/get3.php - (警告:file_get_contents()[function.file-get-contents]:文件名不能在第131行的/home/pluspon/public_html/get3.php中为空) – 2011-12-20 16:21:28
I UPDATE my问题与完整代码 – 2011-12-20 16:55:50