Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class A {
- public function __construct(){
- $this->i= new B();
- }
- public function __destruct()
- {
- $this->i->cleanup();
- }
- }
- class B
- {
- public function __counstruct()
- {
- $this->f = 5;
- }
- public function cleanup()
- {
- if(!isset($this->used)) throw new Exception('nothing to cleanup');
- }
- }
- try
- {
- $x = new A();
- $x->y =5;
- $x = null;
- }catch(Exception $e)
- {
- echo $e->getMessage(),"\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment