Posted 25 July 2006 - 01:28 PM
Im new to php.. May i ask some questions?
If I want to centralize some of the common variables into a php file, and access them through it, may i know how?
Index.php - Default page
Settings.php - Common variables that can be reused by all the php files
- Eg. $Database_name, $Database_username, $Database_password
Category.php -Have a function to retrieve database information.
Index.php include both Settings.php, and category.php by:
But when in Category.php i want to use the variable $Database_name i cannot access it..
Is there a offical way to store all the common variable in the common access php file?
Posted 25 July 2006 - 01:59 PM
If you want to call Category.php by itself and still access variables from within Settings.php, you will need to include Settings.php into Category.php.
Using require_once() will stop any errors that may occur from trying to include the same file multiple times.
Posted 25 July 2006 - 03:26 PM
To be a coder, you must learn how to think and not to give up so easily.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users