简体   繁体   中英

Smarty - Output HTML Variables

I cant understand how Smarty proceed with PHP string variables, with HTML tags:

If I type:

$string = '<b>Hello World</b>'

$smarty->assign('STRING',$string);

The result is Hello World

But if I type:

$string = getString(); // GetString returns "<b>Hello World</b>"

$output = "<div>".$string."</div>";

$smarty->assign('OUTPUT',$output);

The result is "< b >Hello World< /b >" literally, with HTML tags.

So, how can i get in this way, Hello World ?

Thanks.

i checked the below code and its showing same value can u show me how you returning the value in getstring() function

$string = '<b>Hello World</b>';

$smarty->assign('STRING',$string);

function getString()
{
$val='<b>Hello World</b>';
$val=html_entity_decode($val, ENT_QUOTES, 'UTF-8');
  return $val;
}

$string = getString(); // GetString returns "<b>Hello World</b>"

$output = "<div>".$string."</div>";

$smarty->assign('OUTPUT',$output);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM