[SOLVED] Calling Class A from Class B
Posted: Sat Nov 29, 2003 11:15 pm
Does anyone know if it's possible to call/use one Class from another, but reference it with it's object name?
For example, the following won't work and I'm hoping someone can show me how to achive this.
For example, the following won't work and I'm hoping someone can show me how to achive this.
Code: Select all
<?php
class A
{
function Test()
{
echo "BOB";
}
}
class B
{
function printBOB()
{
$a->Test();
}
}
$a = new A();
$b = new B();
// I would like the following to print BOB to the page but
// at the moment it won't for obvious reasons.
// Any help would be great.
$b->printBOB();
?>