General Question

frankielaguna's avatar

PHP Classes?

Asked by frankielaguna (256points) September 25th, 2008

I don’t fully understand the purpose of using classes in PHP. Currently I’m using them to organize my code and keep certain functions in a certain class. But I’m looking to understand what exactly are they suppose to be used for. I’ve read a bunch of tutorials and articles written about them, but still have yet to find a straight answer of what they are.

Observing members: 0 Composing members: 0

3 Answers

Mulot's avatar

For adding an object oriented for mto your application, and avoid a lot of code lines, add object behavior in your application, use the MVC patern, and so on. For example you can represent an entry in your DB table with a classe, and this class will allow you to manipulate your Table at a high level, without doing any errors or syntaxe error in the future, and saving a lot of time.

Really useful.

richardhenry's avatar

Read this:

Object orientated PHP will take you a week or more of reading to fully get your head around, but one day not too long from now the concept will click. You’ll wonder how you survived, writing such nonsensical code. ;)

Good luck.

Vincentt's avatar

I can confirm Richard´s answer. I have spent a long, long time whatever the use of classes was, then suddenly it clicked. A large part in achieving this was starting to use a framework (the Zend Framework in my case) and looking into unit testing. It will all fall in its place then, and is highly recommended.

Answer this question




to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
Knowledge Networking @ Fluther