Static classes in PHP via abstract keyword?

后端 未结 10 1980
孤独总比滥情好
孤独总比滥情好 2021-01-31 19:00

According to the PHP manual, a class like this:

abstract class Example {}

cannot be instantiated. If I need a class without instance, e.g. for

10条回答
  •  面向向阳花
    2021-01-31 19:35

    abstract really is meant to indicate a "blueprint", as you call it, for class inheritance.

    Registries generally follow a singleton pattern, which means they it would instantiate itself in a private variable. Defining it as abstract would prevent this from working.

提交回复
热议问题