Jump to content

How to add single quote instead of double quote?


Go to solution Solved by mark107,

Recommended Posts

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?

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

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. "'>";

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);
?>
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.