Problems related to smarty loading

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.