Question about new users of the smarty Template: the system prompts that undefined functions are found in the template.

Source: Internet
Author: User
New to the smarty Template: the system prompts you to find the undefined function template code in the Template: PHPcode {includefile = 'header. tpl '} & lt; formname = & quot; oform & quot; action = & quot; index. php & quot; method smarty template beginner question: prompt to find undefined functions in the template
Template code:
PHP code
  {include file ='header.tpl'}{include file ='footer.tpl'}


Index. php call code:
PHP code
  
  Assign ('title', 'Test title'); $ smarty-> assign ('version', "2011"); $ smarty-> assign ('homepagelink ', 'http: // localhost/Matance1.0/'); $ smarty-> assign ('tablename', 'title'); if (isset ($ _ POST ['ceshi2']) {$ smarty-> assign ('wandoujia ', $ _ POST ['ceshi2']);} $ smarty-> display ('index. tpl ');?>


In the index. make a form on the tpl template, action = "index. php ", index. when php loads a template, it determines that there is a wooden data transfer value. If yes, it will pass the value to the $ wandoujia function in the template.

But after running, always prompt:

Notice: Undefined index: wandoujia in D: \ Program Files \ wamp \ www \ Mantance1.0 \ TemplateFile \ Templates \ default \ templates_c \ Templates. file. index. tpl. php on line 34
Notice: Trying to get property of non-object in D: \ Program Files \ wamp \ www \ Mantance1.0 \ TemplateFile \ Templates \ default \ templates_c \ Templates. file. index. tpl. php on line 34
/>

Tutorial

------ Solution --------------------
First, this is not an undefined function, but an index,
Second, check 34 lines of this file.
D: \ Program Files \ wamp \ www \ Mantance1.0 \ TemplateFile \ Templates \ default \ templates_c \ da1ad7986fcfc741270ca7b7bdceba8d01b88c26. file. index. tpl. php
------ Solution --------------------
If (isset ($ _ POST ['ceshi2']) {
$ Smarty-> assign ('wandoujia ', $ _ POST ['ceshi2']);
}

If wandoujia is not assigned, if wandoujia has no value, an error is returned.
------ Solution --------------------
Change the error level number to 5 or 7, and only report an error. the Notice error can be directly ignored, which has no effect on the site running Hao. we developed our own PHP site in the early stage, because it was not standardized at the time, there were at least hundreds of NOTICE-level errors, but it was still perfect for several years. Now everyone is too lazy to fix it. It doesn't matter.
------ Solution --------------------
If you must correct this NOTICE level problem, you can do this: in addition to judging POST submission in PHP code:
If (isset ($ _ POST ['ceshi2']) {
$ Smarty-> assign ('wandoujia ', $ _ POST ['ceshi2']);
}
You should also use SMARTY in the template to determine whether POST submission exists. Add the SMARTY variable wandoujia if any. Note:

Name:

Try to change:

Name:

This is not necessarily the case here. you 'd better look at the two outputs of the POST submission value template, and insert {$ smarty. post. ceshi2} directly into a tag to display it. Check whether the output of {$ smarty. post. ceshi2} is different between the submitted value and the unsubmitted value. In this way, you can determine whether to add the $ wandoujia variable.

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.