|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-11-10 23:37 UTC] felipe@php.net
-Status: Open
+Status: Feedback
-Package: Unknown/Other Function
+Package: Scripting Engine problem
[2010-11-10 23:37 UTC] felipe@php.net
[2012-03-29 15:16 UTC] php dot net at doppy dot nl
[2012-10-13 18:50 UTC] reeze@php.net
[2012-10-13 18:50 UTC] reeze@php.net
-Status: Feedback
+Status: Not a bug
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 10:00:01 2025 UTC |
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');