I am curious in writing a chaining interface in PHP OOP. I modified this sample code from the php.net website, and I want to take it further - how can I return objects or arrays from this kind of interface?

```
// Declare a simple class
class TestClass
{
    public $foo;

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

    public function __toString()
    {
        return $this->foo;
    }
}

$input = (object)array("title" => "page 1");
$class = new TestClass($input);
echo $class;

```

error,

> 
> Catchable fatal error: Method TestClass::\_\_toString() must return a
>  string value in C:\wamp\www\test\2013\php\fluent\_interface.php on line
>  2
> 
> 
> 

Should I use different magic method instead of `__toString` then?

**EDIT:**
Can I return this as my result,

```
stdClass Object ( [title] => page 1 )

```