Nesting with three levels of quotations

JSW189 picture JSW189 · Sep 30, 2011 · Viewed 20k times · Source

I am trying to create a php variable that has three levels of nested quotes. How do I make a third level around "tackEvent", "downloads", "all", and "nofilter"? The double quotes that I have there are not working.

  $outputList .= "<a href=files/".$content_file ." onClick='_gaq.push
(["_trackEvent", "downloads", "all", "nofilter"]);' >" . $content_name . 
"</a>";

Answer

Nick Brunt picture Nick Brunt · Sep 30, 2011

From here:

  • Outer quote = " (This marks the beginning and end of the string)
  • Inner quote = \" (Escaped as to not flag "beginning/end of string")
  • Third-tier quote = ' (Literal quote)
  • Fourth-tier quote = \' (Literal quote that will be generated as an escaped outer quote)