Re: Can a class instance a property of another class

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



OK, Jochem, I adapted your example and got it working. Thank you very much.

I am still playing with it to better understand. One thing I don't yet understand is the necessity for the getFoo()/getBar() "handshake," especially the getbar() in the BAR class. That doesn't seem to serve any purpose. My adaptation us just a getDummy().

Do they just serve to pass the object by reference?


Ken

--------------------------------------------------------------
On Jan 26, 2007, at 5:47 PM, Jochem Maas wrote:



class Foo
{
	private $var;
	function __construct() { $this->var = "foo"; }
	function getFoo() { return $this->var; }
}

class Bar
{
	private $var;
	private $foo;
	function __construct() { $this->var = "bar"; $this->foo = new Foo; }
	function getBar() { return $this->var; }
function speak() { echo "I am ",$this->foo->getFoo(),$this->getBar (),"\n"; }
}



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux