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')));