Execute php script before every php script?

Put it in its own file and set the auto_prepend_file configuration in the php.ini / .htaccess file to point to it.

Update: Since you mentioned lighttpd in a comment, note that you can configure it like this in the global INI file with PHP 5.3:

[PATH=/vhost/domain.com]  
auto_prepend_file = /vhost/domain.com/foo.php

[HOST=domain.com]
auto_prepend_file = /vhost/domain.com/foo.php

Or you can create the file /vhost/domain.com/.user.ini and do the same:

auto_prepend_file = /vhost/domain.com/foo.php

Leave a Comment