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 Quote 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. Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/184638-private-constructor/#findComment-974741 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.