Problems related to method calls in common. php in ThinkPHP

Source: Internet
Author: User
In ThinkPHP, I created a public function file common. php in the project Common, and wrote a toHtml () method in it. Then, call {$ list directly in the html template. article_content | toHtml ###} isn't that correct? how can I execute this in a small project? in another slightly complicated project, I will say "Calltoundef ThinkPHP" in common. php method call problems
I created a public function file Common. php in the project common, and wrote a toHtml () method in it.

Then, you can directly call {$ list. article_content | toHtml =###} in the html template ###}

This is correct. how can I execute this operation in a small project,
What about Call to undefined function toHtml () in another slightly complicated project?

------ Solution --------------------
Use standard syntax to check whether the call is successful

TP groups. the common. php directory is different.
------ Solution --------------------
Check whether the file is loaded and use the native php code to test whether the file is successful.
------ Solution --------------------
Is it 2.0?

2.0 of available {: function ()}
If not, you can directly use the php source code.

If the methods in common. php are loaded successfully, they can be called directly in the template and program.
------ Solution --------------------
It is best to use native. I like to use native in any framework.

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.