I have a set of custom PHP scripts. They load a main PHP file (to include other files, set settings, etc.) From this script I’d like to insert a callback function that is called by the scripts that included the main file just before ending.
What I intend to do is make a simple custom output cache with ob_get_contents(). I want to do ob_start() in main.php, then have the callback function store the output.
ob_start()can do what you want:When the output buffer is flushed, the function will be called. Output buffers can be nested.