Template engine-a php template issue

Source: Internet
Author: User
I wrote a template class to filter the content tag in the .html file into a normal php tag and then output it. Currently, file_get_contents is used for reading .html. then, regular expression filtering is normal, and the output to the page is a pure string, similar to {code ...} how can I make it... I wrote a template class. the content tag in the html file is filtered into a normal php tag and then output.

Currently, file_get_contents is used for reading .html. then, regular expression filtering is normal, and the output to the page is a pure string, similar

 Here is html...

How can I execute it?

PS: In the past, I used to save the output strings as A. php file and include the file. Now the environment has changed and does not support directory IO. so I want to execute it directly. Is it feasible?

Reply content:

I wrote a template class to filter the content tag in the. html file into a normal php tag and then output it.

Currently, file_get_contents is used for reading .html. then, regular expression filtering is normal, and the output to the page is a pure string, similar

 Here is html...

How can I execute it?

PS: In the past, I used to save the output strings as A. php file and include the file. Now the environment has changed and does not support directory IO. so I want to execute it directly. Is it feasible?

AvailableevalTo execute the string, the followingmy_template_parserIs your own template function. But note:evalThe execution efficiency is very low and there may be memory problems, so we only recommend that you use it locally for testing. Instead, you should replace it with the php file.includeYes.

eval(my_template_parser(file_get_contents('my-template.html')));

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.