Use php to change non-php Output Content

Source: Internet
Author: User
Use php to change non-php output content...


A few days ago, I needed to filter the output content of the page... to replace the domain name...
For example/
Without modifying the template, you can directly correct the output...

Implementation process
1. put all outputs into the output buffer.
2. after the php script is complete, modify and filter the output buffer before outputting it.

The so test is as follows:
The original output is assumed as follows:








Before html is output, add the following code to the php execution to replace the html content.



Then the output is changed







Focus:
1. ob_xxx function output buffer control
2. the register_shutdown_function registers a function that runs when the script ends ..

Note:
1. the output of register_shutdown_function must be of the last register...
2. if there is an output buffer control function in the process, you need to analyze the specific situation and use it.

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.