title: How I can append "PHP echo" code in html <div>
body: <p>I am developing a chat between 2 users. I store the messages in a MySQL database and on chat box page I call AJAX each 2 seconds to get new messages.
  All works fine with plain text messages but now I need to allow users to send also files.</p>
  <p>I append the new messages using:</p>
  <pre><code>$(&quot;#chat_container&quot;).append(`                                                
      &lt;div class=&quot;message-bubble ${clasa} &quot;&gt;
          &lt;div class=&quot;message-bubble-inner&quot;&gt;
              &lt;div class=&quot;message-text&quot;&gt;${output_response.Result[i].out_Message}&lt;/div&gt;
          &lt;/div&gt;
          &lt;div class=&quot;clearfix&quot;&gt;&lt;/div&gt;
      &lt;/div&gt;
  `);
  </code></pre>
  <p>My chat_container is:</p>
  <pre><code>&lt;div id = &quot;chat_container&quot; class=&quot;message-content-inner&quot;&gt;
  &lt;/div&gt;
  </code></pre>
  <p>${output_response.Result[i].out_Message} is the plain text that I store in mysql databased. For files I am uploading them to server using a php script that returns me the path and then i store the path as a message in database like:</p>
  <pre><code>&lt;a href='upload/1619779744.jpg'&gt;Picture&lt;/a&gt;
  </code></pre>
  <p>Because of this the user will see that the message is actually a link and when he clicks on it he goes to
  https://server/upload/1619779744.jpg and he downloads the picture which is good.</p>
  <p>The problem is that I want to add some security to the site and not show direct path to files in link.</p>
  <p>For this I implemented this class <a href="https://github.com/sujeetkrsingh/Secure-Download-Url" rel="nofollow noreferrer">https://github.com/sujeetkrsingh/Secure-Download-Url</a>
  It works good in a separated file using:</p>
  <pre><code>&lt;div class=&quot;message-text&quot;&gt;&lt;a href=&quot;&lt;?php echo $encrypturl-&gt;getDownloadLink('upload/1619779744.jpg'); ?&gt;&quot;&gt;AWS11 Logo&lt;/a&gt;&lt;/div&gt;
  </code></pre>
  <p>This will return to user the link <a href="https://server.com/download.php?f=2f4df28349d56457b897f2ed3966799735564add3bef41c0" rel="nofollow noreferrer">https://server.com/download.php?f=2f4df28349d56457b897f2ed3966799735564add3bef41c0</a> which hides the actual path of the file.</p>
  <p>The problem is that if I store in database <code>&lt;a href=&quot;&lt;?php echo $encrypturl-&gt;getDownloadLink('upload/1619779744.jpg'); ?&gt;&quot;&gt;AWS11 Logo&lt;/a&gt;</code> instead of  <code>&lt;a href='upload/1619779744.jpg'&gt;Picture&lt;/a&gt;</code> the link of the file is
  <code>https://server/%3C?php%20echo%20$encrypturl-%3EgetDownloadLink(%27upload/1619779744.jpg%27);%20?%3E</code> which is wrong.</p>
  <p>So the question is how I can append HTML + PHP code using jquery append function?
  In my chat file I included the class in the beginning of file using <code>&lt;?php require_once(&quot;EncryptUrl.php&quot;); $encrypturl=new EncryptUrl(); ?&gt;</code> and I renamed the file from .html to .php</p>