Wrapping quotes around a php id in XML
I've got this line of code:
$xml_output .= "\t<Event=" . $x . ">\开发者_如何转开发n";
And it will output:
<Event=0>
<Event=1>
<Event=2>
etc etc through my loop.
I need it to output as this (with the quotes around the number):
<Event="0">
<Event="1">
<Event="2">
Any help, and I'm sure it's simple would be greatly appreciated!
$xml_output .= "\t<Event=\"" . $x . "\">\n";
PHP Strings
To specify a literal single quote, escape it with a backslash (\). To specify a literal backslash before a single quote, or at the end of the string , double it (\\). Note that attempting to escape any other character will print the backslash too.
$xml_output .= "\t<Event=\"" . $x . "\">\n";
However, that is not valid xml.
$xml_output .= "\t<Event=\"" . $x . "\">\n";
The slash escapes the quote for output. More information about double quoted strings can be found in the PHP manual
精彩评论