由于某种原因,当我使用fopen时,我收到以下错误:
无法打开流:HTTP包装器不支持/examplefolder/examplefile.php中的可写连接
当我使用它时:
<?php
$myFile = "http://url.com/" . $_COOKIE['user'] . "/current_pro_pic.xml";
$xmlw = new XMLWriter;
$xmlw->setIndent(true);
$xmlw->startDocument('1.0', 'UTF-8');
$xmlw->startElement('user_current_pro_pic');
$xmlw->writeElement('full_url', "<![CDATA[sometexthere*]]>");
$xmlw->writeElement('time', date('l F jS Y ') . 'at' . date(' h:i A'));
$xmlw->endElement();
$xmlw->endElement();
$xmlw->endElement();
$xmlw->endDocument();
?>
它吐出了这个:
Warning: XMLWriter::setIndent() [xmlwriter.setindent]: Invalid or unitialized XMLWriter object in *** on line 4
Warning: XMLWriter::startDocument() [xmlwriter.startdocument]: Invalid or unitialized XMLWriter object in *** on line 5
Warning: XMLWriter::startElement() [xmlwriter.startelement]: Invalid or unitialized XMLWriter object in ***p on line 6
Warning: XMLWriter::writeElement() [xmlwriter.writeelement]: Invalid or unitialized XMLWriter object in *** on line 7
Warning: XMLWriter::writeElement() [xmlwriter.writeelement]: Invalid or unitialized XMLWriter object in *** on line 8
Warning: XMLWriter::endElement() [xmlwriter.endelement]: Invalid or unitialized XMLWriter object in *** on line 9
Warning: XMLWriter::endElement() [xmlwriter.endelement]: Invalid or unitialized XMLWriter object in *** on line 10
Warning: XMLWriter::endElement() [xmlwriter.endelement]: Invalid or unitialized XMLWriter object in *** on line 11
Warning: XMLWriter::endDocument() [xmlwriter.enddocument]: Invalid or unitialized XMLWriter object in *** on line 12
有谁知道为什么会这样?它不是fyi的文件权限。
答案 0 :(得分:1)
标准从网页获取,始终是只读的。服务器得到一个问题,并将答案发送给您。如果你想给它写XML,你需要发布它,或者把它作为get的变量发送(后者是空间限制的)
答案 1 :(得分:1)
您无法使用http网址引用文件来编写文件。即使文件在同一台服务器上,您也必须为文件提供文件系统路径。
答案 2 :(得分:1)
您必须调用其中一个开放*方法,例如openMemory,openUri
$xmlw = new XMLWriter;
$xmlw->openUri('path_to_save');
// ... or
$xmlw->openMemory();
// ... youe code
$xmlw->setIndent(true);
// ...