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

issues verifying if user is logged in
I am having issues when a user logs in via asp Login control, the IsAuthenticated still seems to com

Display certain image depending on time of year
Hi, I am new to these forums and would really appreciate some advice on a piece of coding I have don

User feedback after MySQL query has been executed
Hi all, I've just registered on PHPFreaks because I've got a question that I simply can't work out b

Echoing If Function?
A script I am using has If statements in the comments form to basically tell the form what to do. Cu

Need some ideas as to how to go about sorting this array...
Here's how the array's are created..

Code: <?php
while ($x = readdir($dp)) {

Keeping track of php uploads
Hello all.

I was looking at the way PHP handles file uploads.
It seems that PHP uses a tem

Using mysql_real_escape_string for displayed content
On my website users can input data into a textarea and it will store it in the mysql database. But,

PHP loop
Okay so I have several "articles" stored in a mysql database and am attempting to echo tho

modifying a property of an object from a different class
I have 2 classes:
- Math
- Distance

in my math class, I have this line:
$distance =

double and single quotes in text fields acting up... help please
Single quotes, when entered into a text field, create an sql error upon Submit. It seems to create t

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