Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP Object-Oriented PHP Basics Building the Recipe Magic Constants

Caitlin Scouler
Caitlin Scouler
7,082 Points

Not getting correct output from '__toString'

Hi guys,

I have finished this lesson and I have my function as

 public function __toString()
  {
    $output = "You are calling a " . __CLASS__ . " object with the title \"";
    $output .= $this->getTitle() . "\"";
    $output .= "It is stored in " . basename(__FILE__) . " at " . __DIR__ . ".";
    $output .= "This display is from line " . __LINE__ . " in method " . __METHOD__ . " method.";
    $output .= "The following methods are available for objects on this class: \n";
    $output .= implode("\n", get_class_methods(__CLASS__));
    return $output;
  }

But the output I am receiving is:

setYield getYield setSource getSource getIngredients

Am I doing something basically wrong?

I am not getting syntax errors,

Many thanks,