Home  >  Article  >  Backend Development  >  Static property issues in singleton pattern

Static property issues in singleton pattern

WBOY
WBOYOriginal
2016-12-01 01:27:191414browse

In singleton mode, three private and one public are usually used. Why do we need to set a static attribute to store the object? Wouldn't it be enough to just set the attribute attribute to private? I beg you for your answer and detailed explanation.

Reply content:

In singleton mode, three private and one public are usually used. Why do we need to set a static attribute to store the object? Wouldn't it be enough to just set the attribute attribute to private? Please give me your answer and detailed explanation.

Because static member methods can only set and get static member properties,

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn