久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      php析構(gòu)函數(shù)的作用

      php析構(gòu)函數(shù)的作用

      php析構(gòu)函數(shù)的作用

      簡言之,析構(gòu)函數(shù)的作用就是釋放內(nèi)存。

      析構(gòu)函數(shù)

      __destruct ( void ) : void

      PHP 5 引入了析構(gòu)函數(shù)的概念,這類似于其它面向?qū)ο蟮恼Z言,如 C++。析構(gòu)函數(shù)會在當(dāng)某個對象的所有引用都被刪除或者當(dāng)對象被顯式銷毀時執(zhí)行,也就是說析構(gòu)函數(shù)是在類實例化的對象銷毀時執(zhí)行。

      析構(gòu)函數(shù)示例

      <?php class MyDestructableClass {    function __construct() {        print "In constructorn";        $this->name = "MyDestructableClass";    }    function __destruct() {        print "Destroying " . $this->name . "n";    } } $obj = new MyDestructableClass(); ?>

      和構(gòu)造函數(shù)一樣,父類的析構(gòu)函數(shù)不會被引擎暗中調(diào)用。要執(zhí)行父類的析構(gòu)函數(shù),必須在子類的析構(gòu)函數(shù)體中顯式調(diào)用 parent::__destruct()。此外也和構(gòu)造函數(shù)一樣,子類如果自己沒有定義析構(gòu)函數(shù)則會繼承父類的。

      析構(gòu)函數(shù)即使在使用 exit() 終止腳本運行時也會被調(diào)用。在析構(gòu)函數(shù)中調(diào)用 exit() 將會中止其余關(guān)閉操作的運行。

      注意:

      ● 析構(gòu)函數(shù)在腳本關(guān)閉時調(diào)用,此時所有的 HTTP 頭信息已經(jīng)發(fā)出。腳本關(guān)閉時的工作目錄有可能和在 SAPI(如 apache)中時不同。

      ● 試圖在析構(gòu)函數(shù)(在腳本終止時被調(diào)用)中拋出一個異常會導(dǎo)致致命錯誤。

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號