Layering Classes
Posted: Thu May 29, 2008 1:18 am
Ok, What I want to do is create multiple different objects, all of the same classes, however each class is "layered"
Visually I want to have this:

Each Yellow Text is a class that I included and = new ClassName;
However, I can't seem to get a new class "created" for each new variable.
For example:
Main.php
_bots.php
_botServ.php
My problem is: I can't get the 2nd bot to showup or work. I'm going to guess there's a rule against that or something. So, I'd like to know what I'm doing wrong, and a way to get around/fix it.
Thanks everyone.
Visually I want to have this:

Each Yellow Text is a class that I included and = new ClassName;
However, I can't seem to get a new class "created" for each new variable.
For example:
Main.php
Code: Select all
<?php
include "bot/_bots.php";
$bot1 = new cBot;
echo $bot1->_conn->hi;
echo "New line test <br />";
$bot2 = new cBot;
echo $bot2->_conn->hi;
?>
Code: Select all
<?php
class cBot {
var $_conn;
function cBot() {
include "_botServ.php";
$this->_conn = new server();
}
}
?>
Code: Select all
<?php
class server {
var $hi = "Hello World<br />";
function server() {
echo "I've been started!<br />";
}
function getHi(){
echo $this->hi;
}
}
?>
Thanks everyone.