Object-Oriented PHP
Class and Object Refresher

Object-Oriented PHP helps your code stay flexible by allowing it to be only defined once but used in many places.

class ClassName {

$className = new ClassName();

We've already learned how to create objects from the classes we define, so let's run through a little refresher. Remember, we use the class keyword to define our classes.

  1. Define a Person class
  2. Create a new variable $me and store a new Person() in it.
Stuck? Get a hint! Hint
Get live, fast support from Codecademy Advisors when you get stuck. Learn more.

Use the new keyword to create your object.

Class creation refresher:

class ClassName {

Object creation refresher:

$myObject = new ClassName();
View Preview