php includes

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dimxasnewfrozen
Forum Commoner
Posts: 84
Joined: Fri Oct 30, 2009 1:21 pm

php includes

Post 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.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: php includes

Post 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.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply