I wrote a template class to filter the contents of the. html file into a normal PHP tag, and then output it.
Currently read. html with the file_get_contents, and then regular filtering is normal, the final output to the page into a pure string, similar to
Here is the HTML ...
How do I get it done?
PS: In the past I used the method of saving these output strings as a. php file, and then include this file. Now that the environment has changed, does not support directory IO, so I would like to directly execute it, is it feasible?
Reply content:
I wrote a template class to filter the contents of the. html file into a normal PHP tag, and then output it.
Currently read. html with the file_get_contents, and then regular filtering is normal, the final output to the page into a pure string, similar to
Here is the HTML ...
How do I get it done?
PS: In the past I used the method of saving these output strings as a. php file, and then include this file. Now that the environment has changed, does not support directory IO, so I would like to directly execute it, is it feasible?
You can use it eval
to execute a string, and the following my_template_parser
is your own template function. However, eval
the attention is inefficient and may have memory problems, so it is only recommended to test locally, formally or replace the PHP file with include
the good.
Eval (My_template_parser (file_get_contents (' my-template.html ')));