Posted by Justin Voelker on 05/17/07 17:38
I have a configuration file that contains the host, username,
password, and database name required for any database connections.
The config file runs through a few if/then/else statements to
determine if the website is local or remote and if it is local if it
is the test site or "live" site then it sets the 4 variables. I am
trying to implement a webstats package that has it's own config file.
I would the new config file to be able to use the same variables as my
config file. The problem I am encountering is that the new config
file has all of its variables inside of a class and I can't seem to
get to my variables from within it. Right now the file starts like
this:
<?php
class SlimStatConfig {
/** Database connection */
var $server = "localhost";
var $username = "username";
var $password = "password";
var $database = "database";
....
?>
What I am envisioning is something to the effect of:
<?php
include('/additionalfiles/config.php');
class SlimStatConfig {
/** Database connection */
global $dbhost;
global $dbuser;
global $dbpasswd;
global $dbname;
var $server = $dbhost;
var $username = $dbuser;
var $password = $dbpasswd;
var $database = $dbname;
....
?>
I have never worked with classes before. And please spare me the "how
do you call yourself a php developer without knowing how to use
classes." Right now I just would like to get this to work with a
minimal amount of work. Thanks for your help!
Navigation:
[Reply to this message]
|