# destructor access to constants

- Thread: https://externals.io/message/3271
- Original archive: https://news-web.php.net/php.internals/3271
- Started by Ulf Wendel on 2003-07-06T10:27:00+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #3271 — Ulf Wendel — 2003-07-06T10:27:00+00:00

URL: https://externals.io/message/3271#3271

Hi,

I'm wondering if it's a bug to give automatically called destructors 
access to constants (PHP Version 5.0.0b1). I'd expect to be neither able 
to access global variables nor constants after script termination (die()).

Ulf


$dtor = 'global $dtor variable is visible';
define('DTOR', 'DTOR constant is visible');

class dtor {

   function __destruct() {
     global $dtor;
     printf('$dtor = "%s"<br> DTOR = "%s"<br>', $dtor, DTOR);
   }
}

$d1 = new dtor();
unset($d1);

$d2 = new dtor();
 `die()`;

generated output:

$dtor = "global $dtor variable is visible"
DTOR = "DTOR constant is visible"
$dtor = ""
DTOR = "DTOR constant is visible"
