I have a project. It has a good number of PHP files. Each of these files includes a standard header. They don’t include a standard footer.
Now I want to do something just before the end of every page. I can go through each page and add the footer code, but I was wondering if there is an easier way (and I think I’ve seen something like it before, though I might be mistaken).
Is there a way to set a “hook” or “trigger” function that will be executed at the end of a page, from the included header PHP script? I’m thinking of something like set_error_handler but to handle a page close event. Or like C’s atexit function.
Ah, I found the function I was looking for, FINALLY. Believe me, I’ve been searching for this for a while, and just happened upon it!
register_shutdown_function— Register a function for execution on shutdown