Classes and Objects in PHP

php logo

Hi,

I’ve written up a short (2 pages,) document that goes over some of the very basics of object oriented programming - it should take you all of 5 minutes to read.

I wrote this as the preamble to my next video on object oriented PHP where we will actually create living breathing PHP objects.

Here’s a small snippet from the PDF:

How objects are created:

Step 1:

You create a class that ‘describes’ an object. Much in the same way a blueprint ‘describes’ a building. Instead of room dimensions etc … PHP classes / blueprints details a bunch of things about an object:

a. Variables it contains.
b. Functions it contains – yep, classes typically have functions in them.

Objects are much more powerful and complex when compared to functions. As such, there are many other special things that can be found in classes, which are unique to classes. Again, more on that later.

Step 2:

Once you’ve defined your class, you are ready to tell the PHP engine to actually create a class from your blueprint. There are special commands (PHP code,) that tell the PHP engine to create an object from the ‘blueprint’ you described/outlined in a class.

Step 3:

When the PHP script is run (with the code that instructs PHP to create an object … based on the class,) PHP actually creates a living, breathing object based on your class.

What I mean by ‘creates a living, breathing object, is to mean that the object is actually created in (server) memory.

Thanks for reading and watching.

Stefan Mischook

www.killerphp.com
www.killersites.com


This entry was posted on Wednesday, August 1st, 2007 at 9:17 pm and is filed under Beginners PHP Articles, Object Oriented PHP. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

4 Responses to “Classes and Objects in PHP”

  1. Stefan Mischook’s Blog: Classes and Objects in PHP…

  2. [...] On the KillerPHP blog, Stefan Mischook introduces a PDF that he’s created to help beginners get a grasp on working with objects in PHP: I’ve written up a short (2 pages,) document that goes over some of the very basics of object oriented programming – it should take you all of 5 minutes to read. I wrote this as the preamble to my next video on object oriented PHP where we will actually create living breathing PHP objects. [...]

  3. hkarthi says:

    hi

    i am really impressed with your work. i would like to know if you could come up with some kind of tutorial/video, which would help newbies like us on how to build a website using php from scratch? part by part would be nice… thanks to your website and your article, i have already know a bit of php programming and would help me and others like me to understand more about php and develop some cool sites. Thanks!

    karthi :-)

  4. Stefan Mischook says:

    hkarthi,

    Thanks for the positive remarks and I appreciate your suggestion – I will consider it.

    I will be putting out many more PHP videos in the near future.

    Stefan

Created By Stefan Mischook  |  Top of page  go to top of page