I would like to know why in the majority of the examples showed in the forum, nobody uses classes in PHP. Is it a chance? Or really, is nobody using them? Do you know classes advantages?

ch.-

Recommended Answers

All 4 Replies

Why don't you list what you think are the advantages with using classes? Most people do not see any advantages, especially for relatively small web sites.

Specifically for this forum most PHP users here are new to PHP development and thus will be unable to do advanced techniques like OOP.

As a newbie to PHP programming, I think that it is better that the examples here are not shown in a class format. I feel that if someone who is genuinely interested in understanding PHP like myself, would be able to use the working code and make a class out of it themselves. Yeah, examples implementing classes would make it more useful, but then there would be a lot more copy and pasting and not so much learning. I use this site to get some minor details or ideas that aren't easy to find in search engines or on the php documentation. Of course, when someone needs help understanding how classes work and the concepts, examples using classes should be there. Most users that are new to PHP don't focus on reusability anyway. When I started I just wanted it to work. Now I use classes to make things work in various scenarios. It has been a great learning experience like that. I think that stymiee is right about newbies to PHP and OOP, unless they have OOP experience with other languages which they could apply to PHP and so working examples should be enough for them to implement their own classes. I pack all the classes in one external file and so each page that I make just loads that and everything else on that page looks mysterious but practical at the same time.

Thanks World_weapon! Your post is very clear.
In my case, when I started to use OOP in PHP, I saw that my productivity increased notably, and components can be easily adapted and modified by my programmers.

I think that the methodology procedural little by little tends to disappear, like as programming concept (in PHP and other languages).

Well, is not easy for me write in english. I hope you can understand my post. :)
thanks.

ch.-

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.