NYCPHP Meetup

NYPHP.org

[nycphp-talk] Rely on destructor to be called?!

Jakob Buchgraber jakob.buchgraber at googlemail.com
Fri Jul 13 14:09:47 EDT 2007


> It might depend on the setting for ignore_user_abort, if that's off, and 
> the user aborts
> the request I'm not sure if/how the destructors are called.
> 

Good point. I tested this with the following script:
<?php
if (ini_get ("ignore_user_abort")) {
     die ("ignore_user_abort must be disabled");
}

class Foo {
     public function __destruct () {
         file_put_contents ("/tmp/isRun", "ok");
     }
}

$a = new Foo();
sleep (5);
?>

The destructor definitely gets called as the file exists regardless if I 
  abort the request or not.

jakob

-- 
Sun Certified Programmer for the Java 2 Platform, Standard Edition 5.0



More information about the talk mailing list