I have a simple PHP app and also a class which contains some config settings like DB conn string and some paths. Where would I best place the include_once('config/config.php'); code?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is a PHP setting called
auto_prepend_filewhich you can make use of. Set it to a file that is the bootstrap of your scripts:bootstrap.php
You can then later on include everything your application needs to work.
If you don’t want to use that ini setting, you can as well in all your scripts just include the
bootstrap.phpfile at the very top:user/profile.php
It’s generally a good idea to have a central point at the very start in your application, this is commonly called bootstrap.