新手SMARTY问题。。

cash2911 2010-08-09 11:54:46
<?php

include_once("smarty_inc.php");

$name="110";


smarty->assign("title",$name);

smarty->display("index.htm");

?>

就这么短行代码- -!Parse error: syntax error, unexpected T_OBJECT_OPERATOR in E:\www\news\index.php on line 8

提示 smarty->assign("title",$name); 这个有问题。。

我的smarty好像都调用进来了。。我用eclipse打“—>”这个时候smarty的类都在后面有提示了。。

球高手帮忙。。!··
...全文
104 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
cash2911 2010-08-09
  • 打赏
  • 举报
回复
我都放在template文件夹里的。。
cash2911 2010-08-09
  • 打赏
  • 举报
回复
存在的我刚刚建立的呀·
这是我inc文件<?php
include_once("common/smarty/Smarty.class.php");

$smarty = new smarty();
$smarty->template_dir = './templates/'.$smartytpl;
$smarty->compile_dir = './templates_c/';
$smarty->config_dir = './config/';
$smarty->cache_dir = './cache/';
$smarty->caching = false;
$smarty->left_delimiter = "{";
$smarty->right_delimiter = "}";



?>
cash2911 2010-08-09
  • 打赏
  • 举报
回复
要用TPL 后缀吗?··
CunningBoy 2010-08-09
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 cash2911 的回复:]

<?php

include_once("smarty_inc.php");

$name="110";



$smarty->assign("title",$name);

$smarty->display("index.html");

?>

Warning: Smarty error: unable to read resou……
[/Quote]
你的index.html存在吗?文件路径正确吗?
cash2911 2010-08-09
  • 打赏
  • 举报
回复
<?php

include_once("smarty_inc.php");

$name="110";



$smarty->assign("title",$name);

$smarty->display("index.html");

?>

Warning: Smarty error: unable to read resource: "index.html" in E:\www\news\common\smarty\Smarty.class.php on line 1095

怎么提示我函数库有问题- -!
CunningBoy 2010-08-09
  • 打赏
  • 举报
回复
不知道,你的是哪本书,Smarty官方网站的例子是需要加$的,如下:
include('Smarty.class.php');

// create object
$smarty = new Smarty;

// assign some content. This would typically come from
// a database or other source, but we'll use static
// values for the purpose of this example.
$smarty->assign('name', 'george smith');
$smarty->assign('address', '45th & Harris');

// display it
$smarty->display('index.tpl');
床上等您 2010-08-09
  • 打赏
  • 举报
回复
smarty 这个不是对象 应该是 $smarty
还有,你实例化了 smarty 了没??
cash2911 2010-08-09
  • 打赏
  • 举报
回复
3楼好像不是这样啊。我看书上都是这么写的呢·
cash2911 2010-08-09
  • 打赏
  • 举报
回复
我在smarty_inc.php里初始化拉。
softfc 2010-08-09
  • 打赏
  • 举报
回复
smarty->assign("title",$name);
是不是$smarty->assign("title",$name);这样写
CunningBoy 2010-08-09
  • 打赏
  • 举报
回复
你没有做对象初始化
<?php
include_once("smarty_inc.php");
$name="110";
$smarty = new Smarty;
$smarty->assign("title",$name);
$smarty->display("index.htm");
?>

4,250

社区成员

发帖
与我相关
我的任务
社区描述
国内外优秀PHP框架讨论学习
社区管理员
  • Framework
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧