You can write a php file with just MySQL connection detail and store it as connection.php. And then you can include it in every php file that requires to connect to the DB using the
You can make use of
too but this might error out some time with Too many connection error.
As the scripts are not readable from the browser in txt mode you don't have to worry about the security issues too.