core error

stdclass in PHP

Posted on: 26/07/2011

What

stdClass is php’s generic empty class.

Why

Using PHP’s stdClass feature you can create an object, and assign data to it, without having to formally define a class.

How

You can quickly create an object out of the stdClass to hold data in it:

$movie          = new stdClass;
$book->name     = "Back to the Future";
$book->director = "Robert Zemeckis";
$book->cast     = array('Michael J. Fox', 'Christopher Lloyd', 'Lea Thompson');
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


    • Justin Cooney: Great comic, this made me laugh!
    • Justin Cooney: Interesting, I didn't know about the Google App Engine, I'm glad I found your article on it!

    Categories

    %d bloggers like this: