只要任何PHP脚本的执行开始,是否可以触发一个函数的调用?是否可以在PHP脚本执行开始后自动调用函数?
例如
<?php
Include 'a.php';
Include 'b.php';
?>
所以我想实现尽快a.php只会包括呼叫应触发的功能。
应该有像register_shut_down这样的东西,但是这个功能在脚本关闭时间执行。
只要任何PHP脚本的执行开始,是否可以触发一个函数的调用?是否可以在PHP脚本执行开始后自动调用函数?
例如
<?php
Include 'a.php';
Include 'b.php';
?>
所以我想实现尽快a.php只会包括呼叫应触发的功能。
应该有像register_shut_down这样的东西,但是这个功能在脚本关闭时间执行。
是的,这是可能的,使用行.htaccess文件:
php_value auto_prepend_file "prepended.php"
或者你的php.ini里当然,但如果您在同一台服务器上托管多个网站,我不会推荐它。
它的工作。谢谢。 – 2011-06-03 11:20:38
是的,你可以做到这一点:
http://php.net/manual/en/ini.core.php#ini.auto-prepend-file
Specifies the name of a file that is automatically parsed before the main file. The file is included as if it was called with the require() function, so include_path is used.
The special value none disables auto-prepending.
它很有效。谢谢。 – 2011-06-03 11:21:15
和顺便说一句,我是30秒更快xD – dynamic 2011-06-03 11:51:19
您的意思是“何时启动脚本”或“何时包含/需要脚本”? – Yeroon 2011-06-03 11:16:42
是Yeroon,只要脚本启动 – 2011-06-03 11:18:08
在'__construct()中调用该方法' – diEcho 2011-06-03 11:21:12