Note that there are some explanatory texts on larger screens.

plurals
  1. POWhen will __destruct not be called in PHP?
    text
    copied!<pre><code>class MyDestructableClass { function __construct() { print "\nIn constructor\n"; $this-&gt;name = "MyDestructableClass"; } function __destruct() { print "\nDestroying " . $this-&gt;name . "\n"; } } $obj = new MyDestructableClass(); </code></pre> <p>When the above script is in a <strong>complex</strong> environment,the <code>__destruct</code> won't get called when <code>exit</code>,but I can't reproduce it easily.Have someone ever noticed this ?</p> <p><strong>EDIT</strong></p> <p>I'll post the whole stuff here,it's the testing environment of symfony,which means you can easily reproduce it if you are familar with the framework:</p> <pre><code>require_once dirname(__FILE__).'/../bootstrap/Doctrine.php'; $profiler = new Doctrine_Connection_Profiler(); $conn = Doctrine_Manager::connection(); $conn-&gt;setListener($profiler); $t = new lime_test(0, new lime_output_color()); class MyDestructableClass { function __construct() { print "\nIn constructor\n"; $this-&gt;name = "MyDestructableClass"; } function __destruct() { print "\nDestroying " . $this-&gt;name . "\n"; } } $obj = new MyDestructableClass(); $news = new News(); $news-&gt;setUrl('http://test'); $news-&gt;setHash('http://test'); $news-&gt;setTitle('http://test'); $news-&gt;setSummarize('http://test'); $news-&gt;setAccountId(1); $news-&gt;setCategoryId(1); $news-&gt;setThumbnail('http://test'); $news-&gt;setCreatedAt(date('Y-m-d H:i:s',time())); $news-&gt;setUpdatedAt(date('Y-m-d H:i:s',time())); $news-&gt;save(); exit(); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload