php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33290 __destruct and shutdown functions are not called
Submitted: 2005-06-09 23:36 UTC Modified: 2010-12-20 11:54 UTC
From: gasper dot kozak at tobonet dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.* OS: *
Private report: No CVE-ID: None
 [2005-06-09 23:36 UTC] gasper dot kozak at tobonet dot com
Description:
------------
The __destruct method of a simple class (not inherited) is not called, same goes for shutdown function.

URL of the problem: http://www.kje.si/iass/lib/App/test_destruct.php

Works with PHP 5.0.3 + Apache2, running on 2.6.11-gentoo, which is my other server.
URL of the working script:
http://dev.tobonet.com/kje.si/lib/App/test_destruct.php

The code below is the stored into a file, nothing else is there, no other files included, nothing.

The configure command is copied from phpinfo:
'./configure' '--prefix=/usr' '--host=i686-pc-linux-gnu' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--datadir=/usr/share' '--sysconfdir=/etc' '--localstatedir=/var/lib' '--with-apxs2=/usr/sbin/apxs2' '--with-config-file-path=/etc/php/apache2-php5' '--without-pear' '--disable-bcmath' '--with-bz2' '--disable-calendar' '--with-cpdflib' '--disable-ctype' '--with-curl' '--with-curlwrappers' '--disable-dbase' '--enable-dio' '--disable-exif' '--without-fam' '--without-fbsql' '--without-fdftk' '--disable-filepro' '--enable-ftp' '--with-gettext' '--without-gmp' '--without-hwapi' '--without-iconv' '--without-informix' '--without-ingres' '--without-interbase' '--without-kerberos' '--enable-mbstring' '--with-mcrypt' '--without-mcve' '--disable-memory-limit' '--without-mhash' '--without-mime-magic' '--without-ming' '--without-mnogosearch' '--without-msql' '--without-mssql' '--with-ncurses' '--without-oci8' '--without-oracle' '--with-openssl' '--with-openssl-dir=/usr' '--without-ovrimos' '--disable-pcntl' '--without-pcre-regx' '--without-pfpro' '--with-pgsql' '--with-pspell' '--without-recode' '--enable-shmop' '--without-snmp' '--enable-soap' '--enable-sockets' '--without-sybase' '--without-sybase-ct' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--with-tidy' '--disable-wddx' '--without-xsl' '--without-xmlrpc' '--disable-yp' '--with-zlib' '--disable-debug' '--without-cdb' '--with-db4' '--without-dbm' '--with-flatfile' '--with-gdbm' '--with-inifile' '--without-qdbm' '--with-jpeg-dir=/usr' '--with-freetype-dir=/usr' '--with-t1lib=/usr' '--with-ttf=/usr' '--enable-gd-jis-conf' '--enable-gd-native-ttf' '--with-png-dir=/usr' '--with-tiff-dir=/usr' '--without-xpm-dir' '--with-gd' '--with-imap' '--with-imap-ssl' '--with-ldap' '--without-ldap-sasl' '--with-unixODBC' '--without-adabas' '--without-birdstep' '--without-dbmaker' '--without-empress' '--without-esoob' '--without-ibm-db2' '--without-iodbc' '--without-sapdb' '--without-solid' '--with-mysqli' '--with-mm' '--without-msession' '--without-sqlite' '--enable-dba' '--with-readline' '--without-libedit' '--enable-versioning'

Reproduce code:
---------------
<?php
// set error displaying to full
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', true);

function OnShutdown()
{
  echo "OnShutdown function called.\n";
}

// register this function to be run at script shutdown
register_shutdown_function('OnShutdown');

// define a class with a destructor
// taken from php.net example for __destruct
class MyDestructableClass
{
  function __construct()
  {
    print "In constructor\n";
    $this->name = "MyDestructableClass";
  }
  
  function __destruct()
  {
    print "Destroying " . $this->name . "\n";
  }
}

// create a class
$obj = new MyDestructableClass();
?>

Expected result:
----------------
Text output:

In constructor
OnShutdown function called.
Destroying MyDestructableClass

Actual result:
--------------
Text output:

In constructor

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-06-09 23:54 UTC] helly@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

It is being called, RTFM.
 [2010-12-20 11:54 UTC] jani@php.net
-Package: Tidy +Package: Scripting Engine problem
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 30 21:00:03 2025 UTC