English 中文(简体)
如何在应对后打电话给谁?
原标题:How to call destructor after response in php?

我有一个聊天板,它将一些数据节省到用户正在发送的 d。 在向用户发出回复之后,我想将其节省下来(网络呼吁缓慢)。

我可以在“旋风”中这样做,但我原能这样做。

用户将投入作为要求——“和”;我们处理——“和”;我们把产出作为回应发送用户;,我们希望储存数据

  class A
  {
      function __construct()
        {
          echo "Hello World";
        }
      function __destruct()
        {
          sleep(15); //I want this to happen after response is being send
        }
      function calc()
        {
          echo "Progress World";
        }
  }
问题回答

PHP s garbage collector and object destruction are automatic processes managed by the runtime, so you don t have direct control over when destructors are called. You can add your cleanup function in finally block of exception handling.

try{
 // your code
}catch(Exception $e){
 // exception handling
}finally{
 //perform cleanup task or destructor here
}




相关问题
Using SimplePie with CodeIgniter and XAMPP

I am using CodeIgniter 1.7.2 with XAMPP 1.7.2 on a Windows computer. I am trying to make use of SimplePie. I followed all the instructions I could find: a copy of simplepie.inc is in my applications/...

Multiple Sites with common files

I have developed over 50 sites that all use the exact same files other than CSS and IMAGES, I currently duplicate the files each time I create a new site and upload different css and images. What ...

http server validation

I finish a litle http server, writing from scratch. I would like to be sure that my imlementation is conforme to the HTTP specifications. W3C give us tools for HTML/XML conformance, but i see nothing ...

热门标签