If I have a config.php file with variables in it like so...
config.php:
$cnf['dbhost'] = "0.0.0.0";
$cnf['dbuser'] = "mysqluser";
$cnf['dbpass'] = "mysqlpass";
How can I then access these variables from a class which is in another file, such as...
inc/db.class.php:
class db() {
function connect() {
mysql_connect($cnf['dbhost'], $cnf['dbuser'], $cnf['dbpass']);
}
}
$db = new db();
So, I can use the class in another file such as...
index.php:
<html>
<?php
include('config.php');
include('inc/db.class.php');
$db->connect();
?>
</html>