Problems with strings containing
Posted on 16th Feb 2014 07:03 pm by admin

Hey all,

I have encountered something strange in a script. I am trying to write an XML header and then fill in the file:
Code: $xmlFile = "fetchableData.xml";
$fh = fopen($xmlFile, 'r+');

$housingData = updateHousingAndReturnXML();
$xmlData = '<?xml version="1.0" ?>'.$housingData;

// echo $xmlData;

fwrite($fh,$xmlData);
fclose($fh);
This code fills the file with the contents of $housingData, but <?xml version="1.0" ?> is not added. If I break up <? it will add it but then I get errors when parsing the XML.

Echoing the string also doesn't work with <?.

I guess what is happening is that the string is getting parsed by the PHP engine for some reason. Escaping <? doesn't work.

I am assuming I am missing something basic. But the manual doesn't say anything about <? being parsed in strings.

Help?

Thanks

No comments posted yet

Your Answer:

Login to answer
263 Like 48 Dislike
Previous forums Next forums
Other forums

Variable Clash
In the past I've had variables clash. For example:

Code: <?php
$c = 5;
$ca

foreach iterator
Hi Guys
Does the foreach loop have an inbuilt iterator ?

Redirect not working after making a POST/GET
Hi Everyone,

I am a novice in PHP. Here I have 2 pages, one page with a textbox and button an

Multidimensional Array into an Html table, help!
Hello all, I am new to HTML/PHP so any help would be great.

I have a multidimensional array f

Content-Disposition: attachment; filename=... not working as i thought it should
taken the following code from the php.net site the script is not working.

what is not happeni

xml
<?php

echo "<h1>XML Articles</h1>";

$home

insert quotes
Hi,

I have an output like this:
Code: john,18,Cancer
How can I change this to
Code:

Generate PDF
Hi guys,

I would like to know if there is a way to generate pdf when clicking on a link. In f

displaying email without attracting a ton of spam
Hello,

this is maybe the wrong place to ask.
How would you display an email address on a w

PHP5 - AJAX help
I've been following the tutorial on w2schools (http://www.w3schools.com/php/php_ajax_database.asp) a

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash