For some reason when I use fopen I get the following error:
出于某种原因,当我使用fopen时,我收到以下错误:
failed to open stream: HTTP wrapper does not support writeable connections in /examplefolder/examplefile.php
无法打开流:HTTP包装器不支持/examplefolder/examplefile.php中的可写连接
And when I use this:
当我使用它时:
<?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();
?>
It spits out this:
它吐出这个:
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
Does anyone know why this is happening? It isn't the file permissions either fyi.
有谁知道为什么会这样?这不是fyi的文件权限。
3 个解决方案
#1
1
Standard gets from a web page, are always read only. The server gets a question and sends you its answer. If you want to write XML to it you would need to post it, or, send it as a variable of get (the latter is space restricted)
标准来自网页,始终是只读的。服务器得到一个问题,并将答案发送给您。如果你想为它写XML,你需要发布它,或者把它作为get的变量发送(后者是空间限制的)
#2
1
You cannot write a file by referring it using a http url. Even if the file is on same server, you have to give filesystem path to the file.
您不能使用http url引用它来编写文件。即使文件位于同一服务器上,您也必须提供文件系统路径。
#3
1
you must call one of open* methods like openMemory, openUri
你必须调用一个open *方法,比如openMemory,openUri
$xmlw = new XMLWriter;
$xmlw->openUri('path_to_save');
// ... or
$xmlw->openMemory();
// ... youe code
$xmlw->setIndent(true);
// ...
#1
1
Standard gets from a web page, are always read only. The server gets a question and sends you its answer. If you want to write XML to it you would need to post it, or, send it as a variable of get (the latter is space restricted)
标准来自网页,始终是只读的。服务器得到一个问题,并将答案发送给您。如果你想为它写XML,你需要发布它,或者把它作为get的变量发送(后者是空间限制的)
#2
1
You cannot write a file by referring it using a http url. Even if the file is on same server, you have to give filesystem path to the file.
您不能使用http url引用它来编写文件。即使文件位于同一服务器上,您也必须提供文件系统路径。
#3
1
you must call one of open* methods like openMemory, openUri
你必须调用一个open *方法,比如openMemory,openUri
$xmlw = new XMLWriter;
$xmlw->openUri('path_to_save');
// ... or
$xmlw->openMemory();
// ... youe code
$xmlw->setIndent(true);
// ...