Recipe 7.12. Calling Methods on an Object Returned by Another Method7.12.1. ProblemYou need to call a method on an object returned by another method. 7.12.2. SolutionCall the second method directly from the first: $orange = $fruit->get('citrus')->peel(); 7.12.3. DiscussionPHP is smart enough to first call $fruit->get('citrus') and then invoke the peel( ) method on what's returned. This is an improvement over PHP 4, where you needed to use a temporary variable: $orange = $fruit->get('citrus'); $orange->peel(); Another victory for PHP 5! |