The constructors should not return anything.
If you want to echo an object, you have to define how to form its string representation with the magic method __tostring
:
class DBFactory {
function __tostring(){
return 'Need to echo';
}
}
$db = new DBFactory();
echo $db;