GuitarGod Posted June 23, 2009 Share Posted June 23, 2009 Hi folks. I'm building a simple template engine and need help parsing PHP. For getting the HTML source of the file, I use the file_get_contents function. In the template, I have simple strings like <!-- FOR ...etc... --> which using the str_replace function, gets changed into <?php for etc ... ?>. The only problem is, the final output isn't parsed. When I view the source code, I actually see the <?php ... ?>. If you don't understand what I mean I'll post a code example. Is there any way round this? How can I get the final output to be parsed? Thanks a lot Quote Link to comment https://forums.phpfreaks.com/topic/163368-parsing-php-template-engine-help/ Share on other sites More sharing options...
MasterACE14 Posted June 23, 2009 Share Posted June 23, 2009 think your template engine needs to be changed a bit. Quote Link to comment https://forums.phpfreaks.com/topic/163368-parsing-php-template-engine-help/#findComment-861991 Share on other sites More sharing options...
JonnoTheDev Posted June 23, 2009 Share Posted June 23, 2009 I wouldn't use file_get_contents() as it is slow. Checkout smarty and look at its internals http://smarty.net Quote Link to comment https://forums.phpfreaks.com/topic/163368-parsing-php-template-engine-help/#findComment-862050 Share on other sites More sharing options...
Skrol29 Posted June 24, 2009 Share Posted June 24, 2009 If you echo() a string which contains PHP code, then the code is not parsed, it is just displayed. Eval() can parse a string code, or include() can parse an external PHP script. For a simple template engine, why don't use TinyButStrong ? Quote Link to comment https://forums.phpfreaks.com/topic/163368-parsing-php-template-engine-help/#findComment-862665 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.