Last active
January 1, 2016 06:19
-
-
Save FinchPowers/8104551 to your computer and use it in GitHub Desktop.
PHP RAII style
This file contains hidden or 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 Toto{ | |
function __construct(){ | |
print "CONSTRUCT!\n"; | |
} | |
function __destruct(){ | |
echo "DESTROY\n"; | |
} | |
} | |
function coco(){ | |
$t = new Toto(); | |
echo "Toco will go out of scope\n"; | |
} | |
coco(); | |
echo "Program done\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment