mark107 Posted May 4, 2014 Share Posted May 4, 2014 I'm working on my php as I'm generating to make the xml output. I need some help with my php as I want to add the single quotes in the <programme channel= tag to make it like this: <programme channel='101 ABC FAMILY' start='20140504113000' stop='20140504131000'> On mine the output show like this: <programme channel="101 ABC FAMILY" start="20140504113000" stop="20140504131000"> The problem are lie in this line: $xml .= " <programme channel='$my_id $channel' start='$stoptime' stop='$starttime'>"; Can you please tell me how i can make the output with the single quotes instead of using double quotes? Link to comment https://forums.phpfreaks.com/topic/288235-how-to-add-single-quote-instead-of-double-quote/ Share on other sites More sharing options...
Jacques1 Posted May 4, 2014 Share Posted May 4, 2014 Is there any reason why the looks of the document are so super-important for you? XML doesn't care whether it's a single or a double quote. Both delimit attributes, and that's it. Link to comment https://forums.phpfreaks.com/topic/288235-how-to-add-single-quote-instead-of-double-quote/#findComment-1478167 Share on other sites More sharing options...
mark107 Posted May 4, 2014 Author Share Posted May 4, 2014 Because it is my script and it is my own work to use so it does bother me!!! so how to add the single quote in the <programme channel= tag because on mine mine it will be showing without the quote like this: <programme channel=ABC FAMILY></programme> here is the code: $xml .= '<programme channel=' .$channel. '>'; Link to comment https://forums.phpfreaks.com/topic/288235-how-to-add-single-quote-instead-of-double-quote/#findComment-1478168 Share on other sites More sharing options...
Ch0cu3r Posted May 4, 2014 Share Posted May 4, 2014 The single quotes are not showing because you are using it as the string delimiter. If you want to print a literal single quote you'll need to escape it $xml .= '<programme channel=\'' .$channel. '\'>'; //OR $xml .= "<programme channel='" .$channel. "'>"; Link to comment https://forums.phpfreaks.com/topic/288235-how-to-add-single-quote-instead-of-double-quote/#findComment-1478175 Share on other sites More sharing options...
mark107 Posted May 4, 2014 Author Share Posted May 4, 2014 thanks Ch0cu3r, but the code you have post the single quotes are still not showing because i'm still using the string delimiter. Any idea? Link to comment https://forums.phpfreaks.com/topic/288235-how-to-add-single-quote-instead-of-double-quote/#findComment-1478179 Share on other sites More sharing options...
Ch0cu3r Posted May 4, 2014 Share Posted May 4, 2014 The code I posted is syntactically correct. You sure you tested it correctly? The \' will print a single quote echo 'One \'two\' three'; // outputs: one 'two' three echo "One 'two' three"; // outputs: one 'two' three Link to comment https://forums.phpfreaks.com/topic/288235-how-to-add-single-quote-instead-of-double-quote/#findComment-1478180 Share on other sites More sharing options...
mark107 Posted May 4, 2014 Author Share Posted May 4, 2014 it still don't work for me, please see it here: http://67.23.248.61/~ytestbox/test_xml.php here is the update code: <?php $my_id = '101'; $channel = 'ABC FAMILY'; $starttime = '2014-05-04'; $stoptime = '2014-05-05'; $xml .= '<programme channel=\'' .$channel. '\'>'; //$xml .= "<programme channel='".$channel."' start='".$starttime."'>"; //$xml .= "<programme channel='$my_id $channel' start='$starttime' stop='$stoptime'>"; $xml .= '</programme>'; header("Content-Type: text/xml"); echo $xml; $handle = fopen("myChannel.xml", "w"); fwrite ($handle, $xml); ?> Link to comment https://forums.phpfreaks.com/topic/288235-how-to-add-single-quote-instead-of-double-quote/#findComment-1478181 Share on other sites More sharing options...
Ch0cu3r Posted May 4, 2014 Share Posted May 4, 2014 The single quotes are there (to see them you need to right click > view source). For some reason the browser is changing them to double quotes. Link to comment https://forums.phpfreaks.com/topic/288235-how-to-add-single-quote-instead-of-double-quote/#findComment-1478185 Share on other sites More sharing options...
mark107 Posted May 4, 2014 Author Share Posted May 4, 2014 Oh ok thanks anyway Link to comment https://forums.phpfreaks.com/topic/288235-how-to-add-single-quote-instead-of-double-quote/#findComment-1478187 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.