写入并保持后,怎么换行? if(fwrite($fp, $guestbook->saveXML())){echo "成功";写入后并保存后,怎么实现换行,使得下次写入在不同的行 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我的意思是把post过来的内容,写入并保存在xml后,换行,后面写入和保存的内容就可以跟前面的不在同一行了 在哪输入echo " <br>";? if(fwrite($fp, $guestbook->saveXML())) { fwrite($fp,"\n");echo "成功"; 试过了4楼的,没效果,跟没加fwrite($fp,"\n");这个效果是一样的 if(fwrite($fp, $guestbook->saveXML())) { fwrite($fp,"\r\n");echo "成功"; 如果再不行 ,楼主贴上完整代码让大家看看 <?php$guestbook = new DomDocument(); //创建一个新的 DOM对象$guestbook->load('guestbook.xml'); //读取 XML数据$threads = $guestbook->documentElement; //获得 XML结构的根//创建一个新 thread节点$thread = $guestbook->createElement('thread'); $threads->appendChild($thread);//在新的 thread节点上创建 title标签$title = $guestbook->createElement('title');$title->appendChild($guestbook->createTextNode($_POST['title']));$thread->appendChild($title);//在新的 thread节点上创建 author标签$author = $guestbook->createElement('author');$author->appendChild($guestbook->createTextNode($_POST['author']));$thread->appendChild($author);//在新的 thread节点上创建 content标签$content = $guestbook->createElement('content');$content->appendChild($guestbook->createTextNode($_POST['content']));$thread->appendChild($content);//将 XML数据写入文件$fp = fopen("guestbook.xml", "w"); if(fwrite($fp, $guestbook->saveXML())){fwrite($fp,"\r\n"); echo "成功";echo "<script language='Javascript'> parent.location.reload(); </script>";}elseecho "留言提交失败";fclose($fp);?>我就是想把每次读进来的数据重新放在另外一行 fopen("guestbook.xml", "a+"); 看看 $guestbook = new DomDocument(); //创建一个新的 DOM对象$guestbook->load('guestbook.xml'); //读取 XML数据$threads = $guestbook->documentElement; //获得 XML结构的根//创建一个新 thread节点$thread = $guestbook->createElement('thread');$threads->appendChild($thread);//在新的 thread节点上创建 title标签$title = $guestbook->createElement('title');$title->appendChild($guestbook->createTextNode($_POST['title']));$thread->appendChild($title);//在新的 thread节点上创建 author标签$author = $guestbook->createElement('author');$author->appendChild($guestbook->createTextNode($_POST['author']));$thread->appendChild($author);//在新的 thread节点上创建 content标签$content = $guestbook->createElement('content');$content->appendChild($guestbook->createTextNode($_POST['content']));$thread->appendChild($content);//=========================================================$threads->appendChild($guestbook->createTextNode("\n"));//这样来添加换行//=========================================================//将 XML数据写入文件$fp = fopen("guestbook.xml", "w");if(fwrite($fp, $guestbook->saveXML())){//fwrite($fp,"\r\n");echo "成功";echo " <script language='Javascript'> parent.location.reload(); </script>";}elseecho "留言提交失败";fclose($fp); 提交表单的一些编辑效果 WAMP安装和配置 php對數組的處理 帮忙分析一下这段PHP程序里正则表达式的含义 如何判断最后一个字符是 - ,然后把最后的 - 过滤掉 怎么使一个页面只能在框架内显示? !!!!!我的网站资源就着么被偷了,期待达人,来就有分 如何取得字符串的ASCLL码? 请问我在一个页面上做了查询,我想用户点这个查询的一项就可以看到这个项目的信息(在另外一页)怎么做? 请教下各位大神,分销系统的数据库和前端改怎么做?如图 php中file函数的问题 急!急!急!急!急!急!
{
fwrite($fp,"\n");
echo "成功";
{
fwrite($fp,"\r\n");
echo "成功"; 如果再不行 ,楼主贴上完整代码让大家看看
$guestbook = new DomDocument(); //创建一个新的 DOM对象
$guestbook->load('guestbook.xml'); //读取 XML数据
$threads = $guestbook->documentElement; //获得 XML结构的根
//创建一个新 thread节点
$thread = $guestbook->createElement('thread');
$threads->appendChild($thread);
//在新的 thread节点上创建 title标签
$title = $guestbook->createElement('title');
$title->appendChild($guestbook->createTextNode($_POST['title']));
$thread->appendChild($title);
//在新的 thread节点上创建 author标签
$author = $guestbook->createElement('author');
$author->appendChild($guestbook->createTextNode($_POST['author']));
$thread->appendChild($author);
//在新的 thread节点上创建 content标签
$content = $guestbook->createElement('content');
$content->appendChild($guestbook->createTextNode($_POST['content']));
$thread->appendChild($content);
//将 XML数据写入文件
$fp = fopen("guestbook.xml", "w");
if(fwrite($fp, $guestbook->saveXML()))
{
fwrite($fp,"\r\n");
echo "成功";
echo "<script language='Javascript'>
parent.location.reload();
</script>";
}
else
echo "留言提交失败";
fclose($fp);
?>
我就是想把每次读进来的数据重新放在另外一行
看看
$guestbook->load('guestbook.xml'); //读取 XML数据
$threads = $guestbook->documentElement; //获得 XML结构的根
//创建一个新 thread节点
$thread = $guestbook->createElement('thread');
$threads->appendChild($thread);
//在新的 thread节点上创建 title标签
$title = $guestbook->createElement('title');
$title->appendChild($guestbook->createTextNode($_POST['title']));
$thread->appendChild($title);
//在新的 thread节点上创建 author标签
$author = $guestbook->createElement('author');
$author->appendChild($guestbook->createTextNode($_POST['author']));
$thread->appendChild($author);
//在新的 thread节点上创建 content标签
$content = $guestbook->createElement('content');
$content->appendChild($guestbook->createTextNode($_POST['content']));
$thread->appendChild($content);
//=========================================================
$threads->appendChild($guestbook->createTextNode("\n"));//这样来添加换行
//=========================================================
//将 XML数据写入文件
$fp = fopen("guestbook.xml", "w");
if(fwrite($fp, $guestbook->saveXML()))
{
//fwrite($fp,"\r\n");
echo "成功";
echo " <script language='Javascript'>
parent.location.reload();
</script>";
}
else
echo "留言提交失败";
fclose($fp);