Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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,