I am writing a "printer friendly" page viewer that works by searching through the page code for some HTML comment tags and displays only the commented code in a new page.
Everything works except when I run this on a PHP page that pulls data from a database. The code gets displayed instead of being parsed as php.
Does anyone know what I am doing wrong?
Here is the code:
//Print Friendly Page Viewer
$begin_string=('<!-- #BeginEditable "Data" -->');
$end_string=('<!-- #EndEditable -->');
// check if the filename for the page exists
if (!file_exists("$DOCUMENT_ROOT$page"))
{
echo "<B>Error - The page $page does not exist on this site.</B>\n";
}
else
{
// get the page content and place in a string
$fcontents = (join('', file("$DOCUMENT_ROOT$page")));
if(ereg("$begin_string.*$end_string", $fcontents, $pcontents))
{
echo "$pcontents[0]\n";
}
else
{
echo "The page $page was not found on this server.";
}
}