Roland_D Posted June 16, 2011 Share Posted June 16, 2011 Hello guys, I need help. I'm building a "simple" template function that grab an html file containing custom markups and string_replace them with the information it collects as for example title of the page, title of the website, etc... I'm stuck at the last markup which is {_PAGE:CONTENT_}. What happen is I parse the content of the page through a file_get_contents("page.html") and i put the resultant string in a variable i will call $pcontent then I string_replace the markup with $pcontent and voilat... this works great with an HTML page but of course I can't do it with a page.php cause the output needs to be processed server side first. My question is: is there a method I can parse the html code resulting from that php page and put it into a variable to replace it to the markup??? I'm sure I can somehow... HELP Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/239488-parsing-html-code-from-a-php-doc-into-variable/ Share on other sites More sharing options...
jcbones Posted June 16, 2011 Share Posted June 16, 2011 Well, you should really include the file into your script. That way the PHP parser will parse it. You, of course, would have to set the variable somewhere in that script. The sloppy work around would be to put a full registered protocol (URL) into file_get_contents(), if fopen wrappers are enabled, then it will parse the data and return it. Quote Link to comment https://forums.phpfreaks.com/topic/239488-parsing-html-code-from-a-php-doc-into-variable/#findComment-1230265 Share on other sites More sharing options...
Roland_D Posted June 16, 2011 Author Share Posted June 16, 2011 thanks for the reply... yes I thought myself about the sloppy workaround but it's really... sloppy! I think I will have to work on the php file apparently... Even though it's weird I can't find a script or something that does something like that... Thanks again anyways. Quote Link to comment https://forums.phpfreaks.com/topic/239488-parsing-html-code-from-a-php-doc-into-variable/#findComment-1230275 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.