Static property issues in singleton pattern

WBOY
Release: 2023-03-02 10:02:01
Original
1417 people have browsed it

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,

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template