How to delete a PHP object from its class?

后端 未结 7 790
攒了一身酷
攒了一身酷 2021-01-02 06:51

I know that for some that might sound stupid, but I was thinking if I hava a delete() method in a class that removes all the object data (from DB and file system), how can I

相关标签:
7条回答
  • 2021-01-02 07:22

    There is a __destruct() magic method which is a destructor for a PHP Class.

    Maybe you can put your deletion code in there and as soon as all reference to your objects are deleted, this destructor will be called and the data deleted.

    0 讨论(0)
提交回复
热议问题