 <p>If you use Smarty you shouldn't do such thing at all. What's the point of using Smarty and putting HTML code into PHP? There is none.</p> <p>You should use <code>fetch()</code> instead</p> <p>You can do:</p> <pre><code>function test($smarty){ return $smarty-&gt;fetch('testtemplate.tpl'); } $smarty-&gt;assign('mycode', test($smarty)); </code></pre> <p>And in <code>testtemplate.tpl</code> you can simply put:</p> <pre><code>&lt;div style="font-size:13px;font-family:Arial"&gt; &lt;a href='google.com'&gt;sasa&lt;/a&gt; &lt;/div&gt; </code></pre> <p>In Smarty you have 2 methods:</p> <p><code>display()</code> - for displaying template</p> <p><code>fetch()</code> - to fetch template into string and then do anything you want with it</p>