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.