PHP: "Footer Function"?

I have a project. It has a large number of PHP files. Each of these files includes a standard header. They do not include a standard footer.

Now I want to do something just to the end of each 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 saw something like this before, although I could be wrong).

Is there a way to set the hook or trigger function, which will be executed at the end of the page, from the included PHP script header? I am thinking of something like set_error_handler , but to handle the page close event. Or like C atexit .

+4
source share
3 answers

Ah, I found the function I was looking for, FINALLY. Believe me, I was looking for this for a while, and just happened to him!

register_shutdown_function - Register a function to execute on shutdown

+4
source

The auto_append_file parameter in php.ini will require file at the end of each PHP page:

http://us3.php.net/manual/en/ini.core.php#ini.auto-append-file

Please note that this applies to a common site for EVERY PHP file.

+2
source

I think you are thinking about auto_prepend_file and auto_append_file:

http://www.aarongloege.com/blog/web-development/php/automatically-include-files/

0
source

Source: https://habr.com/ru/post/1310162/


All Articles