Jump to content

[SOLVED] echo with multiple levels of quotes


mottwsc

Recommended Posts

This statement will render in HTML:

<b><a href="javascript:animate.show(['why', 'how1', 'how2'])"><img src="show.jpeg" border="0" /></a></b>

 

However, if I want to use an echo statement (because I am controlling it as part of a PHP script), I run into a problem since there are already double quotes around the javascript call and single quotes around arguments within the call.  If I'm going to use echo and wrap the whole thing in double quotes, I would normally use single quotes around the javascript call, but what about the single quotes already there for the arguments?

 

Thank you.

 

By that, I assume that translates when quoted for the echo statement into the following, right?

 

echo '<b><a href="javascript:animate.show([\'why\', \'how1\', \'how2\'])"><img src="show.jpeg" border="0" /></a></b>';

 

Hi mottwsc,

 

No, it will translate as:

 

echo '<b><a href="javascript:animate.show(['why', 'how1', 'how2'])"><img src="show.jpeg" border="0" /></a></b>';

 

The backslashes will not be echo'd

 

Hope this helps.

Archived

This topic is now archived and is closed to further replies.

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