I have a strange problem. I have one file index.php in the root, and 2 files include directory inside the root.
root > index.php , include
include > config.php , db.php
In include/db.php I defined MySQL connection parameters like this:
$hostname = 'localhost';
$username = 'root';
$password = '';
$dbname = 'mydb';
Then I have included this file inside include/config.php :
include 'db.php';
And finally, I've included include/config.php inside index.php.
The problem I have is I have not access to database variables when I run index.php. They are only available if I run include/config.php. But I expected I must have all defined variables inside these 2 files when I included them in index.php.
What is the problem ?