Page 1 of 1

php includes

Posted: Tue Mar 30, 2010 2:04 pm
by dimxasnewfrozen
Is there a way to automatically include a number of files when a page is created? For example automatically including the db connection file without doing the: require('connect.php');

Is there a way to do this with a bootstrapper or .httaccess file. If so, I have no idea where to begin.

Re: php includes

Posted: Tue Mar 30, 2010 2:42 pm
by AbraCadaver
You can use __autoload() or another autoloader to load files automatically for classes. For other files you can set auto_prepend_file in php.ini or .htaccess. I prefer just to have a bootstrap.php file that does everything. If you use an MVC or front controller architecture you can automate a lot of things in the controller code.