Skip to content
Advertisement

Tag: singleton

Can you return another instance of the same class from the constructor function (Singleton Pattern)?

I just came across an answer to another question, https://stackoverflow.com/a/32954854/1682790 In that answer, they use the following: But everything else I’ve seen seems to contradict this section of code, namely that in PHP a constructor always returns the object that’s been instantiated, and ignores the return statement altogether. If that’s actually the case, then this isn’t actually creating a singleton,

Advertisement