php01.php:
//$manu为正确读取的数据
$smarty->assign("mainMenu",$manu);$smarty->display('php01.tpl');
===========================================
php02.php
//引用smarty配置并显示模板
include_once '../main.php';
$smarty->display('php02.tpl'); 
===========================================
php01.tpl (php01对应的模板):
省略其他布局...
{%$mainMenu%}
省略其他布局...
===========================================
php02.tpl
省略其他布局...
<body>
//这里路径是正确的
{%include_php file="php01.php"%}
</body>
省略其他布局...php01.php 单独在浏览器中正常显示
php02.php 当php02.tpl 中去掉 {%include_php file="php01.php"%}也是正常显示但是{%include_php file="php01.php"%}的时候就报错了(错误内容如下):
Fatal error: Call to a member function assign() on a non-object in "..../php01.php" on line 32php01.php的 32行的代码就是:
$smarty->assign("mainMenu",$manu);求帮助,谢谢

解决方案 »

  1.   

    你没有实例化 smarty 类成 $smarty什么学校?学这玩意?
      

  2.   

    补充一下,在两个php里都有
    include_once 'main.php';
    mian.php是有
    $smarty = new Smarty();的
    并且定义了所有smarty的目录
    及边界符号
    $smarty->left_delimiter = '{%';
    $smarty->right_delimiter = '%}';
      

  3.   

    代码不全,而且跟你说,你也是一知半解。
    看这个视频吧。
    http://www.verycd.com/topics/2843130/ 从97章看到107章一个下午时间就可以看完的。
      

  4.   

    没看过smarty 的望码兴叹,帮你顶一下.前段时间说要好好看看thinkphp的结果还是没有按照计划进行。
      

  5.   

    你在$smarty这个类中的一个方法里面include了一个php文件php01.php,这个php文件又调用$smarty类,这个你可以用$this。就是说php01.php的代码改为://php01.php
    //$manu为正确读取的数据
    $this->assign("mainMenu",$manu);$this->display('php01.tpl');
     
    你这样相互引用很容易乱的。
      

  6.   

    我这个英文盲都知道
    Fatal error: Call to a member function assign() on a non-object in "..../php01.php" on line 32

    致命错误:调用一个非对象成员函数assign()"..../ php01.php第32行“
      

  7.   

    嗯, 记得smarty的模板和调用的php文件,不在一个变量作用域,
    所以你那个php02的$smarty在php02.tpl里是操作不到的,
    然后你php02.tpl里调用的php01.php里的$smary又没有能得到assign过来的变量,
    然后你这个乱调的结果有个变量冲突什么的也是很正常的,
    ....
    如果贴出全部代码,可能有人能帮你找个临时解决方案,
    不过如果要继续下去,还是理清的好,
    include_php这个能不用就不用,(它是一定可以不用的)