Page 1 of 1

want to use.. object oriented php.. but how??

Posted: Tue Sep 04, 2007 3:28 am
by claws
hi.. every one..

I am a newbie. I want to use object oriented php but I never found its purpose..

all the things were easy using normal php.
but everyone finds object oriented is very handy and uses it.

I am interested in it. but unable to appreciate it so. unable to use it.

can any one give me a link to some tutorial or explain me. how can i use it for my regular needs.

and any link for object oriented php tutorial will be helpful.

Posted: Tue Sep 04, 2007 4:22 am
by CoderGoblin
Cannot give you any links off the top of my head but would recommend you learn PHP patterns and Test Driven Development (TDD) at the same time. It's probably easier to do all of them at the same time, especially TDD, rather than just learn OO development and get used to a certain method of working then have to relearn a different method of "thinking". Both of these topics can be found using your favourite search engine although some links are www.patternsforphp.com which as far as I can tell has been developed by some people on this forum. For TDD as far as I can tell you have PHPUnit2 and simpletest.

Posted: Tue Sep 04, 2007 5:02 am
by Rovas
A great starter in PHP OOP is this tutorial

Posted: Tue Sep 04, 2007 5:11 am
by playgames
i think a new phper study oop is not good for you.

but class of php can select :o

Re: want to use.. object oriented php.. but how??

Posted: Tue Sep 04, 2007 6:03 am
by onion2k
claws wrote:I am a newbie. I want to use object oriented php but I never found its purpose..
There's nothing that you can do with objects that you can't do with functions. If you look for a "purpose" behind objects you'll never find one. The primary advantages of OOP are:

1. Encapsulation. Sections of code are neatly packaged together in handy objects.

2. Reuse. Because things are neatly packaged it's very easy to reuse them in lots of different places.

3. Organisation. Objects tend to make you separate your code into logical blocks - that leads to better organised code.

They're just a different way of organising stuff. They won't magically make your site quicker, or easier to define the logic for your code, or get more page views, or anything like that. All they'll do is make it easier you write things once and use them again and again. They're a bit easier to test too because they're packaged in a way that you can automate the testing using Unit Tests. That said, those are BIG advantages if you're writing code professionally.

Posted: Tue Sep 04, 2007 6:05 pm
by califdon
Right on, onion2k! Extremely well said and absolutely correct.