Hey,
I've been programming PHP for about 2 years and have dabbled with
classes. I'm working on a project and can't seam to figure out how to
use classes within classes. For example:
--foo.class.php--
<?
class Foo
{
var $test1;
function Foo()
{
require_once('bar.class.php');
$test1=new Bar();
}
function testFooBar()
{
return $this->test1->testBar();
}
}
?>
--bar.class.php--
<?
class Bar
{
var $return;
function Bar()
{
$this->return='FooBar Works!';
}
function testBar()
{
return $this->return;
}
}
?>
--index.php--
<?
require_once('foo.class.php');
$test = new Foo();
echo $test->testFooBar();
?>
index.php will disply a blank page instead of 'FooBar Works!'.
The application of this is to use a MySQL wrapper that I made inside of
another class so that i can do something like $app->genUserList(); and
have it automadically run the SQL query and generate the list for me. I
could just take the functions from the SQL wrapper, but I'd rather not.
I want to have the flexability of adding in new features that use other
classes without the hassle of making the inital class super huge.
Thanks,
th********@gmail.com