Php printing Web page code example this article source reference: Ghost. This is different from the code example for printing web pages in window. pri php.
Reference: http://www.jbxue.com/article/6793.html
We will introduce a php code that can generate pages that are easy to print. many news websites use this function to generate simple and generous pages, removing some unnecessary elements, the entire page only includes the title, release time, content, and other main elements. This is different from window. print.
The specific implementation code is as follows:
">; Print this page
Pass the name of the current page to the pfp. php program. This program uses the "file" function of PHP to process the page as a string. When this page is loaded, the program can add, rewrite, or delete HTML fragments.
Printer Friendly Page
|
Error-The page
"." Does not exist on this site.";} Else {// get the page content and put it in 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" $ fcontents = ereg_replace ('target = \ "_ blank \" ', '', $ fcontents) from the hyperlink ); // replace Mark $ fcontents = ereg_replace ('','', $ fcontents); // display the absolute URL address $ fcontents = ereg_replace ('] *>; ([^] *) ','\ 2(\ 1)', $ Fcontents); // Convert the relative link to an absolute link $ fcontents = ereg_replace ('] *> ([^] *) ',"\ 2(Http: // $ HTTP_HOST/\ 1)";, $ Fcontents); // change the background color back to White $ fcontents = ereg_replace (' |
|
|
|
|