Questions about referencing Smarty in the PHP class?

Source: Internet
Author: User
The problem with referencing Smarty in the PHP class???
Problem Overview:
To call the Smarty method in a class, the following error occurs:
PHP Fatal error:using $this When not in object context in G:\SVN\YCMS\localhost\core\smarty\sysplugins\smarty_internal_d ata.php on line 38
Below the code, I hope you can help me under [app/model/home.php has introduced the _model class through other pages]:
app/model/home.php
PHP Code
  
   
  
   

core/model/index.php
PHP Code
  
   
  
   

Core/config/smarty
PHP Code
  
   
  
   Template_dir = Y_app. DS. ' View ';//Set template directory $smarty->compile_dir = Y_cache. DS. " View_c ";//Set compile directory $smarty->config_dir = Y_app. DS. ' Config '. DS. ' Smarty ';//config directory variable//$smarty->php_handling = Smarty_php_allow; Deprecated set to Smarty_php_allow$smarty->left_delimiter = "{"; $smarty->right_delimiter = "}";//compile# $smarty Compile_check = false;//Compile check variable//cache$smarty->caching = true; The output of the cache template $smarty->cache_dir = Y_cache; Directory name where the template cache is stored # $smarty->cache_lifetime = 1; Cache life Cycle?>

There are no problems with file associations, some of which are not shown here.

The error is pointing to the Smarty source code, which is also posted here:
PHP Code
  
   Public Function assign ($tpl _var, $value = null, $nocache = False)    {        if (Is_array ($tpl _var)) {            foreach ($tpl _v Ar as $_key = $_val) {                if ($_key! = ") {                    $this->tpl_vars[$_key] = new Smarty_variable ($_val, $nocache); 
   }}}        else {            if ($tpl _var! = ') {                $this->tpl_vars[$tpl _var] = new Smarty_variable ($value, $ NoCache);}}}    


Hope you feel free!

------Solution--------------------
Assign needs to be instantiated before it can be referenced, there is a sentence in your class home, Parent::assign () The parent class is not instantiated at all
  • 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.