Help with OOPHP

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

 



I'm hoping you guys can help me out.

I'm not sure if you can do this, but i'm trying to create a class that is build of another class. I also want to be able to do functions on the class1 from within class2.


example:

class fruitBasket{

	private $fuit = array();  //this is a class

	public function addFruit($newFruit)
	{
		$this->fruitBasket[] = $newFruit();
	}

	public makeAllApples()
	{
		foreach($this->fruit AS $value)
		{		
			$value->changeName("apple");
		}	
	}

}



class fruit{

	private $name;

	public __construct($name)
	{
		$this->name = $name;
	}

	public changeName($newName)
	{
		$this->name = $newName;
	}
}

--
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