PHP function or file to run before and after every request

你说的曾经没有我的故事 提交于 2019-12-21 12:21:47

问题


I am wondering if there is a way to specify a php function or file to be called every time a user visits and exits a page on my site. So if a user visits say example.com/ex.php can I have a function called before ex.php is run and after ex.php is finished?

I want to be able to record the time it takes to execute php files on my site and store that so I can run queries later to analyze the info. I would prefer not to have to add code to the beginning and end of every file I want to track.

Thanks in advance.


回答1:


Try auto Append/prepend file ini directive.

http://php.net/manual/en/ini.core.php




回答2:


Apache can log the time taken to serve a request directly. This includes more than just the PHP but may be better depending on your needs.

See mod_log_config docs



来源:https://stackoverflow.com/questions/1938183/php-function-or-file-to-run-before-and-after-every-request

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!