Michael Berkowski has the correct answer, use PHP's auto_prepend_file
You can set this setting per directory using .htaccess (Apache) or .user.ini (CGI, FastCGI)
.htaccess style
php_value auto_prepend_file "file1.php"
.user.ini style
auto_prepend_file = "file1.php"
add the correct file type to the directory you want to modify (folder1, folder2, folder3) to have the auto_prepend_file automatically included, exactly as if you had used require
or include
, as the first script to run.