写入并保持后,怎么换行? 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); 这是为什么 Fatal Error 利用php发送http post,在线等 想要几个函数,大虾们拿出你的资料吧 如何让buff在组合成文件?,我是想上传zip文件在服务器解压 正则表达式问题 帮忙看看程序!运行后不能得出正确结论,请指点!谢谢! PHP如何配置???? 怎么从当前htm或者php转到另一个htm或者php?是不是有个函数? 我想做个网站。大家给个意见啊 自定义一个函数,可以达到array_reverse这个函数的效果,将一个一维数组顺序颠倒 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);