求一函数 html文件转化为字符串 我想你要的是htmlspecialchars()函数吧。。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我的意思是说,有没有一种函数能将上面的1.html 的文件的内容转化为字符串,如果没有的话,能否提示一下怎么解决?? <?php$str = implode("\n", file("1.htm"));?> file_get_content这个在php4.3 以后才行吧我的是 php4.2 还有我想要的是 那个字符串$str="<html><body><input name=user $user$></body></html>"而<html><body><input name=user $user$></body></html> 则是1.html 的原文件不知道我说的意思大家明白了没? function html_clean($content) { $content = htmlspecialchars($content); $content = str_replace("\n", "<br />", $content); $content = str_replace(" ", " ", $content); $content = str_replace("\t", ' ', $content); return $content;}这个就可以了,看看是不是你要的! 多谢各位我的意思大家可能还不明白。但是我已经知道了我把我想要的结果说出来吧,你们运行一下就明白我的意思了首先 是1.html<html><body>name:<input name=user $user$></body></html>然后是 2.php<?$str = implode("\n", file("1.html"));$content = str_replace("$user$", "value=\"me\"", $str);echo $content; ?>运行2.php我想要的就是这个意思,明白了吧 。再此多谢各位好心的帮助。感谢 spacet(空格t) 和 caotian2000() 这下大家的意思应该明白了吧。当然还有其他的解决方法。 能否说来听听 <?php// get contents of a file into a string$filename = "/usr/local/something.txt";$handle = fopen($filename, "r");$contents = fread($handle, filesize ($filename));fclose($handle);$content = str_replace("$user$", "value=\"me\"", $str);echo $content; ?> $string = file_get_content($url) to wuyz124(玖头鸟) 的确,我这样做的意思就是表达 使用模板。我自己这么想用这种方法来实现引用模板。你所说的模板指的是什么??能否详细介绍? php调用dll函数,参数为指针怎么传参数 如何打开80端口? 什么是SSL???怎么实现SSL加密??? 三表关联 关于file_put_contents()大访问量下出现的并发错误BUG 算法谁能优化下 奇怪的sql复合语句问题(php+mysql) 怎么把表格做成这样的? 如何批量插入数据! 现在搞 PHP 的有前途吗?一般是什么公司需要 PHP 程序员?月薪一般多少? 一个值班的程序,大家帮忙看下,多谢 用mb_substr函数为什么会出乱码?
如果没有的话,能否提示一下怎么解决??
$str = implode("\n", file("1.htm"));
?>
这个在php4.3 以后才行吧
我的是 php4.2
$content = htmlspecialchars($content);
$content = str_replace("\n", "<br />", $content);
$content = str_replace(" ", " ", $content);
$content = str_replace("\t", ' ', $content);
return $content;
}这个就可以了,看看是不是你要的!
我的意思大家可能还不明白。
但是我已经知道了我把我想要的结果说出来吧,你们运行一下就明白我的意思了首先 是1.html<html>
<body>
name:<input name=user $user$>
</body>
</html>然后是 2.php
<?
$str = implode("\n", file("1.html"));
$content = str_replace("$user$", "value=\"me\"", $str);
echo $content;
?>
运行2.php
我想要的就是这个意思,明白了吧 。再此多谢各位好心的帮助。
感谢 spacet(空格t) 和 caotian2000() 这下大家的意思应该明白了吧。
当然还有其他的解决方法。 能否说来听听
// get contents of a file into a string
$filename = "/usr/local/something.txt";
$handle = fopen($filename, "r");
$contents = fread($handle, filesize ($filename));
fclose($handle);
$content = str_replace("$user$", "value=\"me\"", $str);
echo $content;
?>