Is there any question about the reference to smarty in the php class?

Source: Internet
Author: User
Question about referencing smarty in the php class ??? Problem Overview: If you want to call the smarty method in the class, the following error occurs: PHPFatalerror: Using $ thiswhennotinobjectcontextinG: \ SVN \ YCMS \ localhost \ core \ smarty \ sysplugins \ sma php class reference smarty question ???
Problem Overview:
If you want to call the smarty method in the 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_data.php on line 38
I hope you can help me with the following code: [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 the template directory $ smarty-> compile_dir = Y_CACHE.DS. "view_c"; // Set the compilation directory $ smarty-> config_dir = Y_APP.DS. 'config '. DS. 'smarty '; // Configure the directory variable // $ smarty-> php_handling = SMARTY_PHP_ALLOW; // do not approve of setting it to SMARTY_PHP_ALLOW $ smarty-> left_delimiter = "{"; $ smarty-> right_delimiter = "}"; // compile # $ smarty-> compile_check = false; // compile the check variable // Cache $ smarty-> caching = true; // cache template output $ smarty-> cache_dir = Y_CACHE ;// Directory name for storing the template cache # $ smarty-> cache_lifetime = 1; // cache lifecycle?>

There is no problem with File association, and some are not displayed here.

The error message points 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_var 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);            }        }    }


Please kindly advise!

------ Solution --------------------
The assign must be instantiated before it can be referenced. in your class home, the parent class parent: assign () is not instantiated.

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.