php output single quotes
The following outputs double quotes. How can I get it to output single quotes?
<?php
$xml_output = "<?xml version=\"1.0\"?>\n";
$xml_output .= "<I song='song'>";
echo $xml_output;
The output is <I song="song" />
Output should be &l开发者_运维知识库t;I song='song' />
It's not due to PHP engine.
$ cat so.php
<?php
$xml_output = "<?xml version=\"1.0\"?>\n";
$xml_output .= "<I song='song'>";
echo $xml_output;
?>
$ php -q so.php
<?xml version="1.0"?>
<I song='song'>
Are you looking at the output in Firebug (or similar)? Browsers (and extensions) may change the quotes (and formatting and other things) to suit but that doesn't mean they aren't getting sent like you're doing.
There's nothing wrong with your code. A single quote in a double-quote string is a single quote.
using your code as-is, will output single quotes around the song value, but viewing it in IE or another xml viewer might show it differently.
try checking with wget or view source.
The output is probably correct, but you are reading it after it's passed through some XML parser (for example, in your web browsers "show source" window).
精彩评论