anujgarg Posted December 10, 2009 Share Posted December 10, 2009 Hello, Can we create a constructor as private? If yes, what is the use of it? If no, why can't we make it? Please suggest... Thanks Anuj Link to comment https://forums.phpfreaks.com/topic/184638-private-constructor/ Share on other sites More sharing options...
Daniel0 Posted December 10, 2009 Share Posted December 10, 2009 Yes you can. You may do it if you do not want it constructed outside an existing object of that type for whatever reason. Link to comment https://forums.phpfreaks.com/topic/184638-private-constructor/#findComment-974730 Share on other sites More sharing options...
Mchl Posted December 10, 2009 Share Posted December 10, 2009 See Singleton pattern example here: http://php.net/manual/en/language.oop5.patterns.php Link to comment https://forums.phpfreaks.com/topic/184638-private-constructor/#findComment-974741 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.