易截截图软件、单文件、免安装、纯绿色、仅160KB

php生成html问题 - PHP / 基础编程

<?php
$mysql="localhost";
$dbname="root";
$dbpwd="";
$db="news";
$conn=@mysql_connect($mysql,$dbname,$dbpwd) or die("连接数据库失败!");
@mysql_select_db($db,$conn) or die("选择表1失败!");
mysql_query("set names 'gb2312' ");
$query=mysql_query("SELECT ask.id, ask.title, askanswer.content from ask, askanswer");
while($row=mysql_fetch_array($query))
{
 $id=$row[0];
 $title=$row[1];
 $content1=$row[2];
  $path="html/";
  $path=$path.$id.".html";
  $fp=fopen("tmp.htm","r"); //只读打开模板
  $str=fread($fp,filesize("tmp.htm"));//读取模板中内容
  $str=str_replace("{title}",$title,$str);
  $str=str_replace("{content1}",$content1,$str);//替换内容
  fclose($fp);
  $handle=fopen($path,"w"); //写入方式打开新闻路径
  fwrite($handle,$str); //把刚才替换的内容写进生成的HTML文件
  fclose($handle);
  echo "生成成功"."<br>";
}
?>


这个代码为什么执行后会如图1:

图1

(图1)
生成的两个HTML文件的标题是对的,但是内容却不一样:如图2,图3
图2


图2

图3
图3


图3
file_get_contents
file_put_contents


相关问答:

[HJ_34] 在HTML网页下,用JS 打开LINUX下的记事本

如题,在WINDOWS底下的CODE会,但在LINUX下不知道如何实现,JS的代码应该是不一样的。 求教。

分不够再加。

http://topic.csdn.net/u/20100113/08/17ba1e71-4c33-43f6-91a5-0e031c86e5ed.html
linux ......

问一个PHP和smarty的日期问题 - PHP / 基础编程

index.php内容:
  $smarty->assign('name',strtotime('-0'));
  $smarty->display("index.html");
index.html内容:
{$name|date_format:'%Y-%m-%d'}<hr>
{$ ......

HTML 的简单语法问题 求教

<span id="Label1">如果能看到这个标签 说明我们已经能从HTML 页面上获取了这个元素控件传递到Silverlight应用程序中 </span>
  <br />
  <input type="sub ......

php网站发布问题! - PHP / 基础编程

菜鸟求救!!
  现在我手头有一个php+oracle的网站。。服务器是linux系统
  
  请各位告诉我如何发布。。。我是新手。谢谢了!!
安装一个apache,把php文件放到apache的发布目录下, ......

php联接多个数据库的问题

mssql_select_db("f1",mssql_connect("localhost","sa","sa"));
mssql_select_db("f2",mssql_connect("192.168.0.1","sa","sa") ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号