Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
An example of PHP's autoload function along with some exception handling.
PHP
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
Classes
README
controller.php

README

This is just a really basic example of how to use PHP's autoload function to automatically load classes when they are called.  For fun I threw in some exception handling as well to further illustate the OOP approach.

To invoke this just run it from the command line using: 'php controller.php' and you will see the following output:

Original object var_dump:
object(Social)#1 (4) {
  ["email"]=>
  string(30) "nicholas@nicholaskreidberg.com"
  ["service"]=>
  string(7) "Twitter"
  ["user"]=>
  string(7) "@niczak"
  ["url"]=>
  string(18) "twitter.com/niczak"
}

Calling getter methods [original object]...

nicholas@nicholaskreidberg.com
@niczak
Twitter
twitter.com/niczak

Setting new values ...


Modified object var_dump:
object(Social)#1 (4) {
  ["email"]=>
  string(16) "niczak@gmail.com"
  ["service"]=>
  string(8) "Facebook"
  ["user"]=>
  string(6) "niczak"
  ["url"]=>
  string(26) "http://facebook.com/niczak"
}

Calling getter methods [modified object]...

niczak@gmail.com
niczak
Facebook
http://facebook.com/niczak
Something went wrong with that request. Please try again.