Hi,
Everybody has probably seen the "shopping cart" example (in PHP manual) that illustrates the use of a class.
I understand how to "add" an another object -defined in a different class (Food), with its own methods - to that same "cart" (Restaurant).
//------------------------------------------
$entree = new Food("beef");
$desert = new Food("cake");
$rest = new Restaurant("Five Star");
$rest->addFood($entree);
$rest->addFood($desert);
//------------------------------------------
Then a couple of screens further (after storing the $rest object in a session) I call a function that returns an array with all Food objects. Don't see any difficulty here.
But I just don't seem to figure out how I can call a function from the Food class???
Extending the restaurant class is not the answer since I don't want to add any functionality; I just want to "manage" the restaurant (add/remove food objects).