Reputation: 75
Is it at all possible to have a class return false
instead of an object reference? It would make error handling very clean. Consider the code:
$page = new PageContent('www.google.com');
if ($page)
// do stuff
else
// handle error
Upvotes: 2
Views: 165
Reputation: 125147
No. But you can throw
an exception in the __construct()
method, and handle that.
Upvotes: 5