Jump to content

Using mutiple classes question


x1nick

Recommended Posts

Don't quite know where I got this idea from but wondering if im going along the wrong lines of thinking.

 

Basically I have a main class called `cms` where all my main functions are held for including files etc

 

Now within my other class, for example `mysql` I want to be able to access the data set within cms->cfg

Now what is the best way to do this without using global $cms, thorugh

class mysql extend cms

May work but that dosent

 

class cms {
var $cfg = array();

function addcfg($key,$value) {
$cfg[$key] = $value;
}
}
$cms = new cms();

 

mysql:

 

class mysql extend cms {
function connect() {
$user = $this->cfg['username'];
#do my sql connect..
}
}
$db = new mysql();

 

So basically how can I get access to the cms class within mysql without using global.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.