Hi there.
I was wanting to do a similar thing that I do in perl ion php. I'll explain. What I want to do is call a class with a single parameter, if that parameter is not one of the few that I am expecting I effectively want to log an error and return 0 or undef.
So my class looks a little like this..
class My_Type
{
var $value;
var $type;
var $logger;
function My_Type ($type)
{
switch ($type) {
case 'foo':
$this->type = 'foo';
$this->value = 1;
break;
case 'bar':
$this->type = 'bar';
$this->value = 2;
break;
default:
// I dont recognise this type.. return 0?
return 0;
}
}
}
And in my main code, something like
$type = new My_Type('wibble');
print get_class($type);
Now no matter if I return 0 or not it still returns the class. Is there an easy way to test to see if the class call worked?