Does anyone have opinions about best practices for error handling in PHP classes? I program in Java, ASP, and other languages, but am a PHP newbie.
Suppose I have a class C with a variable V that must be greater than 0:
Class C {
var $V;
function setV(newV) {
if ($newV < 0) {
**** WHAT NOW? ****
One approach is to use an error reporting variable that the caller can check:
var $errorMessage;
…
unset($errorMessage);
if ($newV < 0) {
$errorMessage = "V must be greater than zero.";
return;
Do you use/recommend this approach, or is there as better way?
Kieran