Re: singleton in php?
| From: | - - | Date: | Fri, 07 Sep 2018 05:55:53 +0000 |
| Subject: | Re: singleton in php? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-326548@lists.php.net to get a copy of this message | ||
unsubscribeOn September 2, 2018 at 3:15 PM Jeffry Killen <jekillen@prodigy.net> wrote:Hello;I
have been trying to get a better understanding of "singleton".It is defined as a class
that can only produce one instance of itself.In the online explanation, that is accomplished by a
private constructor function that produces an instanceof the class within its instance.But in php I
am of the understanding that a constructorfunction has to be made public and can't return
anything.Here is the online reference I am looking at:https://www.techopedia.com/definition/15830/singletonSo,
at some point it seems that the class instance has tobe exported via a return statement at some
point, otherwisehow would it be used in other code?Is there a part of the manual that addresses
this?I have a hard copy text* on PHP that addresses the singletonand factory pattern, but I have not
been able to completelycomprehend either of these.*I don't have immediate access to the book
and don't rememberthe title, but the publisher is Friends of Ed / (Apress).I have been further
thrown off by the use of singletonto refer to an object literal in javascript.I realize that this in
not about javascript but the conceptand this use of the term has me confused.More than one object
literal can be created and subsequentlycloned by code, so how is it a singleton, in the general
sense?Thank you for time and attention.JK