PHP Classes

Additional Note

Recommend this page to a friend!

      Simple Singleton  >  All threads  >  Additional Note  >  (Un) Subscribe thread alerts  
Subject:Additional Note
Summary:__clone() issue
Messages:2
Author:Fabian Schmengler
Date:2010-01-13 13:31:24
Update:2010-01-14 14:00:17
 

  1. Additional Note   Reply   Report abuse  
Picture of Fabian Schmengler Fabian Schmengler - 2010-01-13 13:31:24
Hi,

I am aware that this class is only for demonstration but it should be noted that the clone constructor has to be made private too, otherwise it is possible to create multiple instances like that: $instance2 = clone $instance;

Solution:

private function __clone() { }

  2. Re: Additional Note   Reply   Report abuse  
Picture of freedelta freedelta - 2010-01-14 14:00:17 - In reply to message 1 from Fabian Schmengler
Yes, you are right, thanks for this note.