This is best illustrated by the code:
class MyClass {
public $arg;
public function __construct ($arg = NULL) {
if ($arg !== NULL) $this->arg = $arg;
return $this->arg;
}
public function returnThisConstruct () {
return $this->__construct();
}
public function returnSelfConstruct () {
return self::__construct();
}
public function returnNewSelf () {
return new self();
}
}
$obj = new MyClass('Hello!');
var_dump($obj);
var_dump($obj->returnThisConstruct());
var_dump($obj->returnNewSelf());
var_dump($obj->returnSelfConstruct());
return self::__construct()returns the value returned by the method __construct. It also runs the code again in the constructor. When called from the class itself __construct, the return self::__construct()will actually return the constructed class as usual, as usual.
return new self(); returns a new instance of the class of the calling object.