snew
snew

Reputation: 101

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 <I song='song' />

Upvotes: 0

Views: 542

Answers (4)

cletus
cletus

Reputation: 625077

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.

Upvotes: 1

Chandra Patni
Chandra Patni

Reputation: 17577

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'> 

Upvotes: 1

Emil Vikstr&#246;m
Emil Vikstr&#246;m

Reputation: 91942

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).

Upvotes: 0

jspcal
jspcal

Reputation: 51904

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.

Upvotes: 0

Related Questions