For example i have 2 file:
//db.php
return array(
'server'=>'localhost',
'db'=>'mydb',
'name'=>'root',
'password'=>'root',
);
and second file:
//index.php
$config = (include 'db.php');
After that $config = 1
if file included or $config = 0
if file not included, but $config
must be array()
in db.php
file.
What a problem?
windows 7x64, apache 2.2, php 5.4
true answer from deceze SHORT OPEN TAG!!! <? The array is not supposed to be output at all; if it is, something's wrong with your file. In this case, PHP isn't configured to handle short open tags
You can use INI file for your DB credentials. Don't forget to deny access to config.ini in .htaccess file.
config.ini
[database]
server = localhost
db = mydb
name = root
password = root
index.php
<?php
$config = parse_ini_file('config.ini');
// Access to credentials
echo $config['server'];
?>