how do i get access to a current instance of class that's already running in PHP?
in my one PHP class, I want to call a function from another that's already running as a server. so i cant create a new instance.
thanks.
p a
how do i get access to a current instance of class that's already running in PHP?
in my one PHP class, I want to call a function from another that's already running as a server. so i cant create a new instance.
thanks.
p a
What you want is called a singleton.
With a Singleton you can have only one instance of your class running on the server.
To do so you must :
static
fieldprivate
constructor so you can't create instances yourselfstatic
method which call the constructor once, and return the only instanceResources :
On the same topic :