title: Place JavaScript code generated by php function in a php variable then show on html page without executing
body: <p>I have following php function</p>
  
  <pre><code>&lt;?php function searchbox_markup(){
  $baseUrl = "example.com"; ?&gt;
  &lt;script type="application/ld+json"&gt;
  {
      "@context": "http://schema.org",
      "@type": "WebSite",
      "url": "&lt;?php echo $baseUrl; ?&gt;",
      "potentialAction": {
          "@type": "SearchAction",
          "target": "&lt;?php echo $baseUrl . 'index.php?page=search&amp;sPattern={search_term_string}'; ?&gt;",
          "query-input": "required name=search_term_string"
      }
  }
  &lt;/script&gt;
  &lt;?php } ?&gt;
  </code></pre>
  
  <p>I want to display the output of above function on my page without executing JavaScript code contained in it, I tried the following but it do not display JavaScript code in html.</p>
  
  <pre><code>&lt;?php
  $snippet = '"' . searchbox_markup() . '"';
  $htmlSnippet = "&lt;pre&gt;".htmlspecialchars($snippet)."&lt;/pre&gt;";
  echo $htmlSnippet;
  ?&gt;
  </code></pre>