Re: wacky object idea

From: Date: Wed, 30 Aug 2000 08:31:24 +0000
Subject: Re: wacky object idea
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-31202@lists.php.net to get a copy of this message
CH>> __string_value is great for writing objects that need to be CH>> displayed - just echo the object, and it does the right thing. I don't see any added value here. Don't echo it, $object->echo() it, what's the big difference? Overriding standard opearotrs can lead to a bad magic easily, when you rapidly lose understanding what's really happening behind your code. CH>> if ($obj->methodThatMightFail()) {} CH>> or CH>> $res = $obj->methodThatMightFail(); CH>> if ($res) {} CH>> CH>> Instead of: CH>> $res = $obj->methodThatMightFail(); CH>> if (is_object($res) && (getclass($res) == 'PEAR_Exception')) { // CH>> failed } Make method return false on failure. CH>> Having real exceptions would solve this also. Or having some way Well, you sorta have them with custom error handler. Though this might be a valid idea too.. -- Stanislav Malyshev stas@zend.com http://www.zend.com/ +972-3-6139665 ext.106

« previous php.dev (#31202) next »