Example code for PHP-printed web pages
Reference to this article: http://www.jbxue.com/article/6793.html
For everyone to introduce a convenient printing page of PHP code, many news sites have this feature, the resulting page is simple and generous, remove some of the extra elements, the entire page only includes the title, release time, content and other main elements. This is different from the Window.print () function Oh.
The specific implementation code is as follows:
">; Print this page
Pass the name of the current page to the pfp.php program, which uses PHP's "file" function to handle the page as a string. When the page is loaded, the program can add, rewrite, or delete HTML fragments.
<title>Printer Friendly Page</title>
|
Error-the page
"." Does not exist in this site. ";} else{//gets the contents of the page and puts it into a string $fcontents = Join (', File ("$page. Inc"),//Ignore the color attribute, convert to ' ignore ' instead of ' color ' $fcontents = Ereg_ Replace (' color ', ' ignore ', $fcontents);//Remove "_blank" in the hyperlink $fcontents = ereg_replace (' target=\ "_blank\" ', ' ", $ fcontents);//replace Mark $fcontents = Ereg_replace (",", $fcontents);//Displays the absolute address of the URL $fcontents = ereg_replace (']*>;([^]*] ' , '\\2(\\1)', $fcontents);//Convert relative link to absolute link $fcontents = ereg_replace (']*> ([^]*) ', "\\2 (http://$HTTP _host/\\1)";, $fcontents);//Background color change back to white $fcontents = ereg_replace (' |
|
|
|
|