Skip to content

Instantly share code, notes, and snippets.

@reenl
Created September 12, 2013 05:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reenl/b045f8c8aebd808f5d89 to your computer and use it in GitHub Desktop.
Save reenl/b045f8c8aebd808f5d89 to your computer and use it in GitHub Desktop.
php __destruct behavior
<?php
class Test
{
public function __destruct() {
echo 'Destructed!'.PHP_EOL;
}
}
// Destructed!
call_user_func(function() {
$test = new Test();
throw new Exception('Stuff just got messed up!');
});
// Not destructed.
$test = new Test();
throw new Exception('Stuff just got messed up!');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment