An error occurred while loading smarty init. inc. phpPHPcodedefine (, str_replace (\, dirname (_ FILE _); includeExtSmarty. class. php; classTplextendsSmarty {function smarty loading
Init. inc. php
PHP code
define ( '', str_replace ( '\\', '/', dirname ( __FILE__ ) ) );include 'Ext/Smarty.class.php';class Tpl extends Smarty { function __construct() { $this->setTemplateDir ( ."/View" ); $this->setCompileDir (."./comp_c" ); $this->left_delimiter = "<{"; $this->right_delimiter = "}>"; parent::__construct(); }}
Index. php
PHP code
include 'init.inc.php';class Index extends Tpl { function index(){ $this->assign('m','asdfasdfasdf'); $this->display('index.html'); }}$tpl = new Index();$tpl->index();
The error message for the Smarty-3.1.11 version is:
PHP code
Fatal error: Call to a member function createTemplate() on a non-object in D:\AppServ\www\smarty\Ext\sysplugins\smarty_internal_templatebase.php on line 47
It's just that I use a common method to avoid problems, such:
PHP code
$smarty = new Smarty();$smarty->setTemplateDir ( . "/View" );$smarty->setCompileDir ( . "/comp_c" );$smarty -> left_delimiter="<{";$smarty -> right_delimiter="}>";include "init.inc.php";$smarty->display("demo.tpl");
I have not solved the problem for a day. I don't know where the problem occurs. please help me...
------ Solution --------------------
Look at your print_r ($ this-> Smarty );
It should not be instantiated successfully, that is, $ this-> Smarty is not a Smarty object