<?php
require('Smarty.class.php');
$smarty = new smarty();
$smarty->template_dir ='E:/PHPCode/sp/Smarty/templates';
$smarty->config_dir = 'E:/PHPCode/sp/Smarty/config';
$smarty->cache_dir ='E:/PHPCode/sp/Smarty/cache';
$smarty->compile_dir ='E:/PHPCode/sp/Smarty/templates_c';
$smarty->assign('hello','Hello World!');
$smarty->display('index.tpl');
?>
以上代码存为:'E:/PHPCode/sp/index_Smarty.php"E:/PHPCode/sp"是我的虚拟目录;
index.tpl文件放在'E:/PHPCode/sp/Smarty/templates'下;
我的php.ini文件的include_path是“include_path = ".;E:\smarty\libs"”
在浏览器中打开时,提示:Parse error: syntax error, unexpected T_VARIABLE in E:\PHPCode\sp\index_Smarty.php on line 3感觉是Smarty没有注册上,大家帮忙看看!
require('Smarty.class.php');
$smarty = new smarty();
$smarty->template_dir ='E:/PHPCode/sp/Smarty/templates';
$smarty->config_dir = 'E:/PHPCode/sp/Smarty/config';
$smarty->cache_dir ='E:/PHPCode/sp/Smarty/cache';
$smarty->compile_dir ='E:/PHPCode/sp/Smarty/templates_c';
$smarty->assign('hello','Hello World!');
$smarty->display('index.tpl');
?>
以上代码存为:'E:/PHPCode/sp/index_Smarty.php"E:/PHPCode/sp"是我的虚拟目录;
index.tpl文件放在'E:/PHPCode/sp/Smarty/templates'下;
我的php.ini文件的include_path是“include_path = ".;E:\smarty\libs"”
在浏览器中打开时,提示:Parse error: syntax error, unexpected T_VARIABLE in E:\PHPCode\sp\index_Smarty.php on line 3感觉是Smarty没有注册上,大家帮忙看看!
具体的配置可以参看smarty的安装说明,如下:
http://www.smarty.net/manual/en/installing.smarty.basic.php
这是我的php.ini
;;;;;;;;;;;;;;;;;;;;;;;;;
; Paths and Directories ;
;;;;;;;;;;;;;;;;;;;;;;;;;; UNIX: "/path1:/path2"
;include_path = ".:/php/includes"
;
;Windows: "\path1;\path2"
include_path = ".;E:\smarty\libs"这样不对吗?
windows环境变量是在右击"我的电脑"->高级->"环境变量"->"系统变量"->"Path"
已经修改了系统变量,又重启了apache,现在提示:
Parse error: syntax error, unexpected T_REQUIRE in E:\PHPCode\sp\index_Smarty.php on line 2
现在找不着
<?php
define('SMARTY_DIR', 'E:/Smarty/libs/'); //提示第二行
require_once(SMARTY_DIR . 'Smarty.class.php');
$smarty = new Smarty();
.....
?>
现在提示:unexpected T_STRING
是因为我使用的例子是网上找来的,都是源代码。里面加有空格。
我重新手工录入了一份就可以显示出“Hello World!”。