-
-
Save reenl/b045f8c8aebd808f5d89 to your computer and use it in GitHub Desktop.
php __destruct behavior
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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