Object of class could not be converted to string

Given a simple PHP construct :

 private $getText;

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

I’m not sure why I am getting the following error :

Object of class MyNamespaceGetText could not be converted to string

I thought you didn’t have to do anything special to assign a class to a variable in PHP ?


Source: oop

Leave a Reply