析构函数
void __destruct ( void )
PHP 5 引入了析构函数的概念,这类似于其它面向对象的语言,如 C++。析构函数会在到某个对象的所有引用都被删除或者当对象被显式销毁时执行。 例子 19-8. 析构函数示例<?php
class MyDestructableClass {
   function __construct() {
       print "In constructor\n";
       $this->name = "MyDestructableClass";
   }   function __destruct() {
       print "Destroying " . $this->name . "\n";
   }
}$obj = new MyDestructableClass();
?>  
 和构造函数一样,父类的析构函数不会被引擎暗中调用。要执行父类的析构函数,必须在子类的析构函数体中显式调用 parent::__destruct()。 注: 析构函数在脚本关闭时调用,此时所有的头信息已经发出。 注: 试图在析构函数中抛出一个异常会导致致命错误。 

解决方案 »

  1.   

    you cannot use "~" in a function name.....
      

  2.   

    php4 没有析构函数 但可以用 register_shutdown_function 来代替register_shutdown_function
    (PHP 3 >= 3.0.4, PHP 4, PHP 5)register_shutdown_function --  Register a function for execution on shutdown 
    Description
    void register_shutdown_function ( callback function [, mixed parameter [, mixed ...]] )
    Registers the function named by function to be executed when script processing is complete. Multiple calls to register_shutdown_function() can be made, and each will be called in the same order as they were registered. If you call exit() within one registered shutdown function, processing will stop completely and no other registered shutdown functions will be called. In PHP 4.0.6 and earlier under Apache, the registered shutdown functions are called after the request has been completed (including sending any output buffers), so it is not possible to send output to the browser using echo() or print(), or retrieve the contents of any output buffers using ob_get_contents(). Since PHP 4.1, the shutdown functions are called as the part of the request so that it's possible to send the output from them. There is currently no way to process the data with output buffering functions in the shutdown function. Shutdown function is called after closing all opened output buffers thus, for example, its output will not be compressed if zlib.output_compression is enabled. As of PHP 4, it is possible to pass parameters to the shutdown function by passing additional parameters to register_shutdown_function(). 
      

  3.   

    从 Php4开始 5是正式支持.
      

  4.   

    学习
    --------------------
    免费asp.net空间申请
    php 空间 100M 50元每年
    顶级域名 50 
    上海京拓科技(www.kingtoo.com)