fork download
  1.  
  2. <?php
  3. class MyDestructableClass {
  4. function __construct() {
  5. print "Конструктор\n";
  6. $this->name = "MyDestructableClass";
  7. }
  8.  
  9. function __destruct() {
  10. print "Уничтожается " . $this->name . "\n";
  11. }
  12. }
  13.  
  14. $obj = new MyDestructableClass();
  15.  
  16. //$arr = get_defined_vars();
  17.  
  18. //var_dump($arr);
  19.  
  20. var_dump($obj);
  21.  
  22. unset($obj);
  23.  
  24. var_dump($obj);
  25.  
  26.  
  27. var_dump($arr);
  28. ?>
  29.  
Success #stdin #stdout #stderr 0.02s 24400KB
stdin
Standard input is empty
stdout
Конструктор
object(MyDestructableClass)#1 (1) {
  ["name"]=>
  string(19) "MyDestructableClass"
}
Уничтожается MyDestructableClass
NULL
array(7) {
  ["_GET"]=>
  array(0) {
  }
  ["_POST"]=>
  array(0) {
  }
  ["_COOKIE"]=>
  array(0) {
  }
  ["_FILES"]=>
  array(0) {
  }
  ["argv"]=>
  array(1) {
    [0]=>
    string(8) "prog.php"
  }
  ["argc"]=>
  int(1)
  ["_SERVER"]=>
  array(15) {
    ["TMPDIR"]=>
    string(11) "/tmp/dubmKS"
    ["PATH"]=>
    string(28) "/usr/local/bin:/usr/bin:/bin"
    ["PWD"]=>
    string(12) "/home/SCcArd"
    ["LANG"]=>
    string(11) "en_US.UTF-8"
    ["SHLVL"]=>
    string(1) "0"
    ["HOME"]=>
    string(12) "/home/SCcArd"
    ["PHP_SELF"]=>
    string(8) "prog.php"
    ["SCRIPT_NAME"]=>
    string(8) "prog.php"
    ["SCRIPT_FILENAME"]=>
    string(8) "prog.php"
    ["PATH_TRANSLATED"]=>
    string(8) "prog.php"
    ["DOCUMENT_ROOT"]=>
    string(0) ""
    ["REQUEST_TIME_FLOAT"]=>
    float(1428544096.3876)
    ["REQUEST_TIME"]=>
    int(1428544096)
    ["argv"]=>
    array(1) {
      [0]=>
      string(8) "prog.php"
    }
    ["argc"]=>
    int(1)
  }
}
stderr
PHP Notice:  Undefined variable: obj in /home/SCcArd/prog.php on line 24