Error solution using $ smarty-> register_object

Source: Internet
Author: User
Use $ smarty-& gt; register_object to report my php & lt ;? Phprequire (& quot; libs/Smarty. class. php & quot;); $ smarty = newSmarty; $ smarty-& gt; template_d use $ smarty-> register_object to report an error
My php


Require ("libs/Smarty. class. php ");

$ Smarty = new Smarty;

$ Smarty-> template_dir = "templates ";
$ Smarty-> cache_dir = "cache ";
$ Smarty-> config_dir = "configs ";
$ Smarty-> compile_dir = "templates_c ";

Class My_Object
{
Function meth1 ($ params, & $ smarty_obj)
{
Return "this is my meth1 ";
}
}

$ Myobj = new My_Object;
// Registering the object (will be by reference)
$ Smarty-> register_object ("foobar", $ myobj );

$ Smarty-> display ('EG _ 15_1.tpl ');

?>

The following error is reported:
Fatal error: Uncaught exception 'smartyexception' with message 'Call of unknown method 'register _ object '. 'In D: \ xampp \ htdocs \ smarty \ libs \ sysplugins \ smarty_internal_templatebase.php: 806 Stack trace: #0 D: \ xampp \ htdocs \ smarty \ eg_15_1.php (22 ): smarty_Internal_TemplateBase->__ call ('register _ object', Array) #1 D: \ xampp \ htdocs \ smarty \ eg_15_1.php (22): Smarty-> register_object ('foobar ', object (My_Object) #2 {main} thrown in D: \ xampp \ htdocs \ smarty \ libs \ sysplugins \ smarty_internal_templatebase.php on line 806

Please help me with it...


------ Solution --------------------
Register_object ==> assign

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.