Cluadia Posted August 18, 2008 Share Posted August 18, 2008 Hi, I'm relatively new to writing php. This may be a rather generalized question, my knowledge of programming as a whole isn't too complete I've tried searching for an answer to this for some time, but I'm struggling in finding what exactly to search for.I'm wondering about what happens when you run into a scenario where you need to put in 3 quotes. Say, you have a php which echos html code. And a scenario where you have to define the onmousedown in say, a link, which uses 1 quote, a javascript function which uses the 2nd one, and the parameters needed to be passed which uses 3 total. It's been something I missed learning a long time ago and would like to correct that.I've been making it by via doing a work around as described below. <?phpecho '<a href="#" name="'. $link_name.$number .'" id="' . $link_description.'" onmousedown="ajax_zee(this.name,this.id);">?> I genuinely appreciate any help on the matter, I thank you! Link to comment Share on other sites More sharing options...
Lulzim Posted August 18, 2008 Share Posted August 18, 2008 if you want to echo a quote in php escape it using a backslash (\)here is an example: <?phpecho "<a href='#' onclick=\"alert('This is an alert.')\">click me</a>";?> read more Link to comment Share on other sites More sharing options...
Synook Posted August 19, 2008 Share Posted August 19, 2008 If you need to nest multiple levels of the same type of quote you can use multiple backslashes (as \\\" => \" => "). echo "function test() { document.write(\"<div onclick=\\\"test\\\"></div>\");}"; Link to comment Share on other sites More sharing options...
Cluadia Posted August 19, 2008 Author Share Posted August 19, 2008 I really, really appreciate it you two, thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.