- 论坛徽章:
- 0
|
本帖最后由 yum2014 于 2014-05-07 15:48 编辑
win7 64位+wamp.
php版本是5.3.
smarty2.6解压后。libs目录改名为smarty文件夹。复制到www下的news目录下。
建立了一个smarty.php文件内容是- <?
- //引用文件
- include "./Smarty/Smarty.class.php";
- $smarty=new Smarty;
- //var_dump($smarty);
- $smarty->template_dir="./templates";//设置模板目录
- $smarty->compile_dir="./templates_c";//设置编译目录。必选的。
- $smarty->config_dir="Smarty/Config_File.class.php";//目录变量
- $smarty->caching=false;//是否使用缓存,项目调试期间,不建议启用缓存
- $smarty->cache_dir="./smarty_cache";//缓存文件夹.可选的。
- $smarty->left_delimiter="<{";
- $smarty->right_delimiter="}>";
- ?>
复制代码 建立一个模板文件xx.htm- <html>
- <head>
- <title>测试</title>
- </head>
- <body>
- <body>
- 欢迎<{$name}>光临smarty网站;
- 年龄:<{$age}>
- </body>
- </body>
- </html>
复制代码 建立一个php文件(i2.php)- <?php
- include('./smarty.php');
- $name="dengwei";
- $age=27;
- $smarty->assign('name',$name);
- $smarty->assign('age',$age);
- #$smarty->display("./templates/xx.htm");
- $smarty->display("./xx.htm");
- ?>
复制代码 而后访问 http://localhost/news/i2.php
结果报错了。。。根本没有显示预期的。。。求问是哪里出错了? |
|