2014-01-30 16:06


  • oop
  • php

Some of my classes declare their constructors as private because an object of such class is only allowed to be created by a static method of the class. May I also declare destructors of such classes as private to keep it symmetric, is it safe?

EDIT: Ok, seems like this is simply not possible:

Fatal error: Call to private AClass::__destruct() from context '' in /script on line 0

(the context is empty and there's no such thing as line 0). For some reason I used to think that the PHP runtime is almighty and can destruct anything it wants.

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享