# status of __destruct

- Thread: https://externals.io/message/6226
- Original archive: https://news-web.php.net/php.internals/6226
- Started by John Huntjens on 2003-12-05T10:45:11+00:00
- Messages: 2
- 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

---

## #6226 — John Huntjens — 2003-12-05T10:45:11+00:00

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

What the status of destruct, should it work?

I am asking because all the simple provided examples work, but in a more
complex situation __destruct is never called.
Is destruct called on a object when a exit is issued?

for debugging I use this destruct:

 function __destruct()
 {
  touch("/tmp/destruct_app.txt");
 }

I am using todays snap (06.30)

Gr,

JOhn

---

## #6237 — Andi Gutmans — 2003-12-05T16:07:07+00:00

URL: https://externals.io/message/6226#6237 · In reply to: #6226

Destructors are only called during a clean shutdown (i.e. no E_ERROR). They 
should actually be called by an `exit()` call. Can you post a short 
reproducing script (maybe with a print instead of a `touch()`) that displays 
this problem?

Andi

At 11:45 AM 12/5/2003 +0100, John Huntjens wrote:
>What the status of destruct, should it work?
>
>I am asking because all the simple provided examples work, but in a more
>complex situation __destruct is never called.
>Is destruct called on a object when a exit is issued?
>
>for debugging I use this destruct:
>
>  function __destruct()
>  {
>   touch("/tmp/destruct_app.txt");
>  }
>
>I am using todays snap (06.30)
>
>Gr,
>
>JOhn
