用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;
?>
并不能显示出页面中的所有代码.
非常谢谢各位. 比如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;
?>
并不能显示出页面中的所有代码.
但你直接输出里面的html代码是会给浏览器解析掉echo htmlspecialchars($content); 这样能看到所有
<?php
$content = file_get_contents("hot.html");
echo htmlspecialchars($content);
?>
貌似啥都没有,我再看看...
$fp = fopen($file, 'r');
$body = fread ($fp, filesize($file));
$file = 'http://www.111cn.net';
$fp = fopen($file, 'r');
$body = fread ($fp, filesize($file));