Search code examples
phpsmarty

Assign html and var value smarty php


I need to assign value for smarty var but it need to be mixed with some html or text like

 {assign var="heading1" value='Hello $user <a href="#">logout</a>'}

HTML works but the $user variable does not.


Solution

  • In order to embed your PHP variable, you must use double quotes in smarty.

    For instance:

    {assign var="heading1" value="Hello $user <a href='#'>logout</a>"}
    

    should concatenate $user for you.