PHPで下記のコードを作って実行しましたが、exitをしても__destructが呼ばれません。
どなたか、なぜこういうことが起きるか説明していただけませんか?
lang
1class MyDestructableClass { 2 function __construct() { 3 print "\nIn constructor\n"; 4 $this->name = "MyDestructableClass"; 5 } 6 7 function __destruct() { 8 print "\nDestroying " . $this->name . "\n"; 9 } 10} 11 12$obj = new MyDestructableClass();
追記:以下がすべてのコードです。Symfonyのテスト環境で、フレームワークさえわかっていれば簡単に複写できるようになっています。
lang
1require_once dirname(__FILE__).'/../bootstrap/Doctrine.php'; 2 3$profiler = new Doctrine_Connection_Profiler(); 4 5$conn = Doctrine_Manager::connection(); 6$conn->setListener($profiler); 7 8$t = new lime_test(0, new lime_output_color()); 9 10class MyDestructableClass { 11 function __construct() { 12 print "\nIn constructor\n"; 13 $this->name = "MyDestructableClass"; 14 } 15 16 function __destruct() { 17 print "\nDestroying " . $this->name . "\n"; 18 } 19} 20 21$obj = new MyDestructableClass(); 22$news = new News(); 23 24$news->setUrl('http://test'); 25$news->setHash('http://test'); 26$news->setTitle('http://test'); 27$news->setSummarize('http://test'); 28$news->setAccountId(1); 29$news->setCategoryId(1); 30$news->setThumbnail('http://test'); 31$news->setCreatedAt(date('Y-m-d H:i:s',time())); 32$news->setUpdatedAt(date('Y-m-d H:i:s',time())); 33$news->save(); 34exit();
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。