From: ziya at atilim dot edu dot tr Operating system: Any PHP version: 4.3.1 PHP Bug Type: Class/Object related Bug description: returning NULL from constructor does no MEAN
When we return NULL from the constructor, our intend is to tell caller that NO OBJECT IS CREATED. But in PHP this case does not work. Please check the following example; <?php class Test{ var $myVar; function Test($val){ if (is_null($val)) return NULL; else $this->myVar = $val; return $this; } } $a = NULL; $t = new Test($a); if (is_object($t)) echo "Although it must be NULL, it says OBJECT"; ?> I am developing a very huge API using PHP and this does not permit us to continue. I think, there should be a way of doing this in a language which support OOP constructs. Sincerely, Ziya Karakaya -- Edit bug report at http://bugs.php.net/?id=22512&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=22512&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=22512&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=22512&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=22512&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=22512&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=22512&r=support Expected behavior: http://bugs.php.net/fix.php?id=22512&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=22512&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=22512&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=22512&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=22512&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=22512&r=dst IIS Stability: http://bugs.php.net/fix.php?id=22512&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=22512&r=gnused