Skip to content

Instantly share code, notes, and snippets.

@reenl

reenl/destruct_example.php Secret

Created Sep 12, 2013
Embed
What would you like to do?
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