spyke01 Posted July 23, 2006 Share Posted July 23, 2006 Ok there will probally be much flaming about this, but here goes. ive seen many people using classes, but ive never used them simply because i dont see a reason to do it in my code. I have seen where people use it to access different style databses, kinda like phpbb does. ive programmed forums, content management systems, trouble ticket systems, and store systems but never once used a class. So heres my question, when(please use a real world example) would i really need to use them? how much more effecient is if to use a class instead of functions with global variables? Quote Link to comment https://forums.phpfreaks.com/topic/15369-why-use-classes/ Share on other sites More sharing options...
Branden Wagner Posted July 23, 2006 Share Posted July 23, 2006 well if your like me you started out with Java, and then learned PHP soooo its a habit.but ive always wondered the same thing.. is there a reason? so far all ive found out it that its a matter of habit. Quote Link to comment https://forums.phpfreaks.com/topic/15369-why-use-classes/#findComment-62279 Share on other sites More sharing options...
effigy Posted July 23, 2006 Share Posted July 23, 2006 The larger the project, the more global variables and functions collide. What if you wanted to use a friends code that had a bunch of global variables that overwrote yours? I haven't done a lot of OPP, and the little I have done has been in Perl, not PHP. Before I understood what it was, I had the same notion as you--What's the point? This is understood in time. Any basic OPP primer should lay out the advantages for you, such as abstraction and inheritance. I see it as a containment system. You have your own "namespace" in which you cannot run into anyone else, and you can also control what the user can and cannot do within this area--private or public methods, e.g. Quote Link to comment https://forums.phpfreaks.com/topic/15369-why-use-classes/#findComment-62280 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.