From:             
Operating system: Windows 7
PHP version:      5.2.14
Package:          Unknown/Other Function
Bug Type:         Bug
Bug description:about __destruct

Description:
------------
I am not good at english.. 



Read the following code ..



An error occurs when you run it..

(there will be white-screen in my codes.)







Chinese :

如果你能看懂中文.那最好不过了.
上面的代码我认为__destruct被继承之后,
会导致下面两个类的对象在释放时出现无法找到static
$childs的错误.
但是在我的代码里面他确实没有出现这个错误,
反而运行了很久之后出现了白屏.
看上去很像一个死循环.



Test script:
---------------
error_reporting(E_ALL);

ini_set('display_errors', 'on');



abstract class Father {

   private static $childs = array();



   public static function getChild( $child ) {

       if (!array_key_exists("$child", self::$childs)) {

           self::$childs["$child"] = new $child;

       }

       return self::$childs["$child"];

   }



   public function __destruct() {

       foreach (self::$childs as $i => $child) {

            self::$childs[$i] = $child = null;

       }

   }

}



class Child1 extends Father {}

class Child2 extends Father {}



$child1 = Father::getChild('Child1');

$child2 = Father::getChild('Child2');


-- 
Edit bug report at http://bugs.php.net/bug.php?id=53289&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=53289&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=53289&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=53289&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=53289&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=53289&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=53289&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=53289&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=53289&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=53289&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=53289&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=53289&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=53289&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=53289&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=53289&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=53289&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=53289&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=53289&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=53289&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=53289&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=53289&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=53289&r=mysqlcfg

Reply via email to