Interested in learning how to program objects in PHP? Well, here is somewhat good start. This is just a small post to give you a taste. To seriously get into Object Oriented Programming, there are many concepts that are in books and classes at colleges that can give you the full scope of Object Oriented Programming (OOP).
I recently did a code challenge that involved PHP and MYSQL and wanted to make my submission stand out, so I thought I should do it using OOP. I’ve always wanted to learn OOP for PHP. I have experience doing OOP in Actionscript 3, so I wasn’t starting in the dark with OOP. Anyways, from searching online and books, I compiled this class. I thought this would be a great opportunity to post my findings for anyone out there interested in moving to OOP in PHP.
Below is the class. I would have used the code format thing in WordPress, but it doesn’t seem look nice, so I decided to just post a picture.
Public allows that function or variable to be used outside of the class. You could use private too, which would prevent objects outside of the class to call a function or variable inside a class.
Customer is the name of the object. The six lines, 12-17, are the variables. The MyName function just displays the name of the customer, when you call that function.




