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.
php includes
Moderator: General Moderators
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: php includes
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.