Jump to content


Photo

OOP PHP?


  • Please log in to reply
4 replies to this topic

#1 Jessica

Jessica
  • Staff Alumni
  • This is not my name.
  • 8,982 posts
  • LocationDallas, TX
  • Age:26

Posted 13 April 2006 - 09:06 PM

I'm having trouble understanding the concept of OOP and non-OOP programming. I was taught that PHP is an OOP language, yet someone is telling me they can code PHP without it being OOP. Can someone please explain OOP in an easy to understand way, and if PHP can be non OOP, an example?
My goal in replying to posts is to help you become a better programmer, including learning how to debug your own code and research problems. For that reason, rather than posting the solution, I reply with tips and hints on how to find the solution yourself. See below for useful links when you get stuck.

How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq

Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!

#2 titangf

titangf
  • Members
  • PipPipPip
  • Advanced Member
  • 58 posts
  • LocationColorado, USA

Posted 13 April 2006 - 09:28 PM

Honestly OOP (or Object-Oriented Programming), at least from my perspective is a time saver. Yes, you can write out the code, but if you happen to have to repeat the code or use the same function more than once it helps to have it in a form that you don't have to rewrite it.

I'm sure there are some different answers than just mine... but that's how I interpert it.
[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--][a href="http://www.csszengarden.com/" target="_blank"]css zen garden - beautiful design with the programmer in mind[/a][!--colorc--][/span][!--/colorc--]

[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--]Time is the invention of man to gauge what his achievements have been before he fades to dust.[!--colorc--][/span][!--/colorc--]

#3 Jessica

Jessica
  • Staff Alumni
  • This is not my name.
  • 8,982 posts
  • LocationDallas, TX
  • Age:26

Posted 13 April 2006 - 09:30 PM

Sorry, maybe I didn't ask clearly enough. I know there are advantages to using OOP, but I don't understand what it is. It's classes & functions, having objects...but I don't know how you would write PHP without those things.
My goal in replying to posts is to help you become a better programmer, including learning how to debug your own code and research problems. For that reason, rather than posting the solution, I reply with tips and hints on how to find the solution yourself. See below for useful links when you get stuck.

How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq

Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!

#4 titangf

titangf
  • Members
  • PipPipPip
  • Advanced Member
  • 58 posts
  • LocationColorado, USA

Posted 13 April 2006 - 09:47 PM

(others can have a different take on this... so please don't chew me out for saying this... but i'm going to say it anyways...)

PHP was designed to look and behave very similiarly to programming in C. Basically if you had a large program that needed to be run... it would be more benifitial to you in the long run to use OOP. They say that a picture is worth a 1000 words... so I hope that this helps more than i can explain.

[img src=\"http://www.tornadopixel.com/images/thecode.jpg\" border=\"0\" alt=\"IPB Image\" /]

I hope that this helps some...
[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--][a href="http://www.csszengarden.com/" target="_blank"]css zen garden - beautiful design with the programmer in mind[/a][!--colorc--][/span][!--/colorc--]

[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--]Time is the invention of man to gauge what his achievements have been before he fades to dust.[!--colorc--][/span][!--/colorc--]

#5 Yesideez

Yesideez
  • Members
  • PipPipPip
  • Advanced Member
  • 2,334 posts
  • LocationDevon, UK

Posted 14 April 2006 - 01:32 PM

I've been programming for the past 25+ years and in all this time and in all the languages I've used I've only ever learnt what I need to know when I need it. This way I've picked up some languages with ease. I've never known many of the fancy terms like OOP and classes.

I've just had to dig this up usign Google:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]OOP, Oops. Object-oriented programming. A method of computer programming where items of related data together with routines associated with it are treated as a single 'object' or item in the program. For example, to implement an on-screen dialogue box requires graphic images for the box and its buttons, details of how they are to be arranged, and a facility to detect which button has been pressed. All of these would be combined into a self-sufficient object which would take as input, the name of the dialogue, perhaps some text to be displayed and the names of the buttons, and return as output a code indicating which button had been pressed. The advantage of OOP is that manipulation of the defined object can be made much easier for the programmer. Languages such as C++ provide special features to assist OOP.[/quote]

Always been a bit of a grey area for me.
Not a pro just an enthusiast :)

if (empty($coffee)) {$coffee=new coffee();}

Please surround any code using the CODE tags - I rarely look at anything without them




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users