Jump to content

Object Oriented Php


skaterdav85

Recommended Posts

Yeah, a lot of professional developers use OOP techniques. If you have a class that does a certain task, it's easy to move it around to other software projects and not have to re-code a bunch of stuff. It's also easier to make changes to the underlying algorithms without having to change all the code that uses them. In the biggest application I'm working on now, I'm using 8 custom classes that I built for various things, and another few that I got online (PDF generation, etc). The classes I built are things to handle config settings, caching data, database work, user sessions, stuff like that, generic things that I can take and use on other projects without needing to change anything.Other things don't really need an entire class. I wanted to simplify handling uploaded files, but instead of an entire class to do that, all that was necessary was a single function. Resizing an image is the same thing, an entire class to handle images might be nice to build, but I wanted a generic image resizing method and all that was required was a single function.

Link to comment
Share on other sites

Yeah, a lot of professional developers use OOP techniques. If you have a class that does a certain task, it's easy to move it around to other software projects and not have to re-code a bunch of stuff. It's also easier to make changes to the underlying algorithms without having to change all the code that uses them. In the biggest application I'm working on now, I'm using 8 custom classes that I built for various things, and another few that I got online (PDF generation, etc). The classes I built are things to handle config settings, caching data, database work, user sessions, stuff like that, generic things that I can take and use on other projects without needing to change anything.Other things don't really need an entire class. I wanted to simplify handling uploaded files, but instead of an entire class to do that, all that was necessary was a single function. Resizing an image is the same thing, an entire class to handle images might be nice to build, but I wanted a generic image resizing method and all that was required was a single function.
how long have you done php development? did it take you a long time to learn oop in php? ... Ive been doing alot of php in my class at school, like creating logins and disseminating rest/soap web services, but it hasnt been object oriented, so i felt like i should learn oop in php. any recommendations as to go about learning it?
Link to comment
Share on other sites

I learned PHP on my own while I was in college, I've been using it for around 7 years or so. It didn't take me a long time to understand the OOP concepts because I was using C++ all through college. OOP is a general topic, it's not related to PHP specifically. You might start with a general book to learn OOP concepts in general:http://oreilly.com/catalog/9780596008673/and then a PHP-specific one, to learn how PHP does it:http://oreilly.com/catalog/9781593270773/

Link to comment
Share on other sites

  • 1 month later...
I learned PHP on my own while I was in college, I've been using it for around 7 years or so. It didn't take me a long time to understand the OOP concepts because I was using C++ all through college. OOP is a general topic, it's not related to PHP specifically. You might start with a general book to learn OOP concepts in general:http://oreilly.com/catalog/9780596008673/and then a PHP-specific one, to learn how PHP does it:http://oreilly.com/catalog/9781593270773/
have you read that 2nd book?
Link to comment
Share on other sites

  • 2 months later...

So i've been reading some stuff on OOP in PHP, and ive been told its not good to put html or css in your classes. What if you are pulling data from a database and you are going to loop through the results of the query and output them in a table...Would you put the loop in your view page and just do the query in a method?

Link to comment
Share on other sites

I understand the syntactical basics of how to create objects, but I'm not sure how to group certain things together, or what is the best way to create an object. Say you were creating a blog site, would you separate each module into its own object...and have a blog object to insert and read out entries, an object for the login system, an object for a poll module etc?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...