What is the use of class in PHP and defining functions under it?
In which situation defining a class is usefull in PHP?
Becuase we can do everything without using classes.
Thnx
| SitePoint Sponsor |
What is the use of class in PHP and defining functions under it?
In which situation defining a class is usefull in PHP?
Becuase we can do everything without using classes.
Thnx
Do Good Have Good!
It depends which level of programming you are at. Sure, procedural coding might work fine for you at the beginning, but hey so does code with absolutely no functions
The point is, how organized and structured your code is. Object orientation is a way of thinking about your script. It's strictly not needed, but it can really help with a lot of things. I won't go into detail here, because most likely if you were ready to take on object orientation, you wouldn't be asking. Do a bit of research on Google.
Object orientation, in my opinion, cannot be taught by a tutorial. You can learn the syntax and the basic idea of it, and some of the most common patterns, but it's up to the programmer to expand it out at that point according to his own preferences.
You use classes when you want to use object-oriented approach to PHP web development. Object-Orient makes it easy to write and resuse code. And, yes much of what you can do with OO can be done without it as well.
Bookmarks