IS to possible to auto call a function as soon as PHP script's execution is started?
Is it p开发者_开发知识库ossible to trigger a call to a function as soon as any PHP script's execution is started ?
e.g.
<?php
Include 'a.php';
Include 'b.php';
?>
So what I want to achieve is as soon as a.php is included a call should be triggered to a function.
There should be something like register_shut_down but this function is executed at script shut down time.
Yes you can do that with:
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.
Yes this is possible, using a line in your .htaccess file:
php_value auto_prepend_file "prepended.php"
Or inside you php.ini ofcourse, but I'd not recommend it if you host multiple websites on the same server.
精彩评论