Ayas置き場
RSS Feeds
81月

デストラクタさんとdie()さんと[Ctrl]+[C]様

デストラクタさんはdie()さんは本当にお友達なのだろうか、と疑問に思ったので実験。

PHP:
  1. <?php
  2. class TestClass
  3. {
  4.     function __construct()
  5.     {
  6.         print('construct');
  7.         die('....' . get_class($this) . ' is dead.....');
  8.     }
  9.     function __destruct()
  10.     {
  11.         print('destruct');
  12.     }
  13. }
  14.  
  15. new TestClass();
  16. ?>

出力

construct....TestClass is dead.....destruct

お友達らしい。

ついでに・・・[Ctrl]+[C]様とはどうなのだろうか。雲の上の方過ぎて駄目だろうけど、大切なのはスピリットさ。

PHP:
  1. <?php
  2. class TestClass
  3. {
  4.     function __construct()
  5.     {
  6.         print('construct');
  7.     }
  8.     function __destruct()
  9.     {
  10.         print('destruct');
  11.     }
  12. }
  13.  
  14. $testObj = new TestClass();
  15. while(TRUE);
  16. ?>

Windowsのコマンド窓にて。

>php test.php

ここで[Ctrl]+[C]

constructError in my_thread_global_end(): 1 threads didn't exit
^C

    ( ̄ ̄)        ∧_∧
     ) (        (・∀・ )?
    /====ヽ      (    )
   (===)      | | |
    ヽ__/      (_(__)

    ( ̄ ̄)∧_∧
     ) ( (・∀・ )
    /====⊂    )キュッキュッ
   (===)Y  人
    ヽ__/ (_) J

     (^Д^) プギャー
    m9  ヽ)
     /  ノ
    ( ̄ ̄)       ∧_∧
     ) (       (・∀・ ) !
    /====ヽ     (    )
   (===)     | | |
    ヽ__/     (_(__)

by Ayas 0 comments Category: PHP

No Comments