Constructor returning value?

Indeed you are correct. Nothing can be done with the return value of a constructor (aside from using the Object it created).

So no, you aren’t missing anything, it’s the developer who wrote that code who is.

It is technically possible to use return values from constructors, if you call the function directly

$obj->__construct();

That would allow you to use the constructor’s return value. However, that is highly uncommon and fairly not recommended.

Leave a Comment