Weird behaviour when writing to a file
Posted: Wed Jan 23, 2008 3:55 pm
Alright so here's the deal.
I am working towards moving all of my companies inventory online to the Google Base service via their XML RSS Feed deal. I have created a PHP script to automatically write the RSS file for me, right? Right. Anyway, so Google requires you to tab-delimit the file, which you know, should be easy.
But for some reason, whenever I try to fwrite or fputs \t \n \r or any escape character it puts the actual characters \ and t into the file. So say the code is
the output in the file would be
instead of
I am opening the file with the 'wb' option.
And unfortunately I am using PHP 4.2.5 (my webhost is a little outdated and is slowly working on upgrading their servers)
Any ideas on why it would be doing this?
I am working towards moving all of my companies inventory online to the Google Base service via their XML RSS Feed deal. I have created a PHP script to automatically write the RSS file for me, right? Right. Anyway, so Google requires you to tab-delimit the file, which you know, should be easy.
But for some reason, whenever I try to fwrite or fputs \t \n \r or any escape character it puts the actual characters \ and t into the file. So say the code is
Code: Select all
fwrite('<blah>grag</blah>\t', $handle);Code: Select all
<blah>grag</blah>\tCode: Select all
<blah>grag</blah><whitespace tab>And unfortunately I am using PHP 4.2.5 (my webhost is a little outdated and is slowly working on upgrading their servers)
Any ideas on why it would be doing this?