PHP - print content from file after manipulation
Posted
by ludicco
on Stack Overflow
See other posts from Stack Overflow
or by ludicco
Published on 2010-04-22T20:15:06Z
Indexed on
2010/04/22
20:23 UTC
Read the original article
Hit count: 241
Hello there, I'm struggling trying to read a php file inside a php and do some manipulation..after that have the content as a string, but when I try to output that with echo or print all the php tags are literally included on the file.
so here is my code:
function compilePage($page,$path){
$contents = array();
$menu = getMenuFor($page);
$file = file_get_contents($path);
array_push($contents,$menu);
array_push($contents,$file);
return implode("\n",$contents);
}
and this will return a string like
<div id="content>
<h2>Here is my title</h2>
<p><? echo "my body text"; ?></p>
</div>
but this will print exactly the content above not compiling the php on it.
So, how can I render this "compilePage" making sure it returns a compiled php result and not just a plain text?
Thanks in advance
© Stack Overflow or respective owner