用php如何得到整页的html代码呢? 比如页面hot.html, 要将hot.html里面的所有html代码都赋值给一个变量, 这个要如何做呢?  如果页面里面有特殊字符要怎么判断处理?
非常谢谢各位. 比如hot.html页面是这样的:
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5" />
<title>Untitled Document</title>
</head><body>
dsdsdsdsds
</body>
</html>
-------------------
这些代码都要得到.
<?php
$content = file_get_contents('hot.html');
echo $content;
?> 
并不能显示出页面中的所有代码.

解决方案 »

  1.   

    http://www.chinaz.com/Program/PHP/01191043462010.html还有 你用file_get_contents 其实是获取了所有的代码
    但你直接输出里面的html代码是会给浏览器解析掉echo htmlspecialchars($content);  这样能看到所有
      

  2.   

    是这样吗?
    <?php
    $content = file_get_contents("hot.html");
    echo htmlspecialchars($content);
    ?>
    貌似啥都没有,我再看看...
      

  3.   

    是啊,,,echo "<P>abc</P>";            肯定不会显示<p>的。     
      

  4.   

    直接echo,然后再源代码,这个准能用
      

  5.   

    好像显示不出来页面的整个html代码....
      

  6.   

    Echo "<textarea style='width:100%;height:200px'>".htmlspecialchars($content)."</textarea>";
      

  7.   

    $file = 'emailcontent.html';
    $fp = fopen($file, 'r');
    $body = fread ($fp, filesize($file));
      

  8.   

    利用绝对路径试一下
    $file = 'http://www.111cn.net';
    $fp = fopen($file, 'r');
    $body = fread ($fp, filesize($file));