当前位置: 动力学知识库 > 问答 > 编程问答 >

php - Smarty can't display variable values

问题描述:

Hello guys I am new to smarty and it seems I can't even get the sample code to work. It looks like a super simple question but I've been stuck in this for hours.

I assigned a couple of values in the php file but when I try to display the value on the front end, it shows up the variable names instead of the values. Below is the php file I got:

<?php

include('Smarty.class.php');

$smarty = new Smarty;

$smarty->template_dir = './tmp';

$smarty->compile_dir = './tmp_c';

$smarty->assign('name', 'george smith');

$smarty->assign('address', '45th & Harris');

// display it

$smarty->display('index.tpl');

?>

Below is the html output

User Information:

Name: {$name}

Address: {$address}

like I said, the $name and $address value can never be read by the html file. Any idea what might goes wrong here?

分享给朋友:
您可能感兴趣的文章:
随机阅读: