For some reason when I use fopen I get the following error:
failed to open stream: HTTP wrapper does not support writeable connections in /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]: Inval开发者_如何学运维id 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.
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)
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.
you must call one of open* methods like openMemory, openUri
$xmlw = new XMLWriter;
$xmlw->openUri('path_to_save');
// ... or
$xmlw->openMemory();
// ... youe code
$xmlw->setIndent(true);
// ...
精彩评论