Secure against what?
If you want it to secure against "rough module", it's not. All defined values will be accessible anywhere in included file (you should use config and unset it unset initialization).
$config = parse_ini_file( 'configs/config.php');
mysqli_connect( isset( $config['host']) ? $config['host'] : 'localhost',
isset( $config['user']) ? $config['user'] : 'root', ...);
// Select DB
unset( $config);
// Prohibit your modules from opening any file
Against webuser? Again no. You're displaying error to end user. You're telling anyone that you're connection to localhost
with user root
if connection fails for any reason (you should use throw an exception, trigger error and notify user just about database error, send mail to yourself and log the error).
And using root
without password is quite a big security issue, but I'm assuming that's just example data.
mysql_*
functions are being deprecated. – ceejayoz Jan 21 '12 at 18:50