代码之家  ›  专栏  ›  技术社区  ›  Cedric

获取退出消息以将其与对象的销毁方法一起使用

  •  2
  • Cedric  · 技术社区  · 16 年前
    $fooinstance = new foo();
    /*do something*/
    exit('bar');
    
    class foo{
      __destruct(){
        //get the exit message ("bar") to do something with it
      }
    }
    

    你好,

    谢谢

    2 回复  |  直到 16 年前
        1
  •  1
  •   Artefacto    16 年前

    文本 exit text that's output before the script dies

    您可以使用输出缓冲来获取文本,但我不确定它是否有用:

    <?php
    $fooinstance = new foo();
    ob_start();
    exit('bar');
    
    class foo{
      function __destruct(){
        $c = ob_get_contents(); //$c is "bar"
      }
    }
    

        2
  •  0
  •   Vladislav Rastrusny    16 年前

    这是不正确的做事方式。为什么需要这种特殊的解决方案?

    推荐文章