Php printing Web page code example

Source: Internet
Author: User
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 ('

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.