Jump to content

Formatting this line correctly in fwrite function


mattykewl

Recommended Posts

Hi, I was wondering if someone could help me, i don't understand how to format

<?php
$xmlfile = fopen("squad.xml", "w");
[color=red]fwrite($xmlfile,"<?xml version="1.0"?>"); [/color]
fclose($xmlfile);
?>

That line, i understand its the "" that will be causing the problem? or it could be something else like the <>??? how could i format this line in fwrite so it can be writen like that into the file but also php-friendly.

Many thanks!!!
Or you could use single quotes to delimit the string, then you don't have to escape the double quotes:
[code]<?php
$xmlfile = fopen("squad.xml", "w");
fwrite($xmlfile,'<?xml version="1.0"?>');
fclose($xmlfile);
?>[/code]

Ken
[quote author=kenrbnsn link=topic=124407.msg515420#msg515420 date=1169998350]
Or you could use single quotes to delimit the string, then you don't have to escape the double quotes
[/quote]

Matty,

What Ken said is very true, and probably in this situation the better way to go.  Having said that, it is important you know how to escape special characters within strings.

Regards
Huggie

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.