Is it possible to create static classes in PHP (like in C#)?

前端 未结 6 1639
南方客
南方客 2020-11-28 01:47

I want to create a static class in PHP and have it behave like it does in C#, so

  1. Constructor is automatically called on the first call to the class
  2. No
6条回答
  •  感动是毒
    2020-11-28 02:09

    you can have those "static"-like classes. but i suppose, that something really important is missing: in php you don't have an app-cycle, so you won't get a real static (or singleton) in your whole application...

    see Singleton in PHP

提交回复
热议问题