Enter your Sign-on user name and password.

Forgot password?
  • Follow us on:
Loading video...

Start Learning Now

Our free lessons will get you started (Flash® 10 required).
Get immediate access to our entire library.

Sign up for Educator.com

Features Overview

  • Get on-demand access to our complete library
  • Search and jump to exactly what you need to learn
  • Track your progress
  • Download practice and lesson files
  • *Ask questions and get answers from our community & instructors

Classes vs. Objects

  • A class provides a definition for a user-defined data type. An object is an instance of a class providing values to a class’s properties.
  • Each instance of a class has their own ‘version’ of a class’s properties, and these are referred to as instance properties.
  • Static properties are class properties whose values are shared between all of the instances of a particular class.
  • A property is declared static in a class definition by using the static keyword:
    public static $numPeople = 0;
  • An object of a class does NOT need to be instantiated to access a class's static properties.
  • The scope resolution operator (::) is used to access static properties.
  • A public static property is accessed from outside of a class definition using the syntax:
    Person::$numPeople; // uses the class name
  • A static property, whether public or private, can be accessed inside a class definition with an alternative syntax that uses the self keyword:
    self::$numPeople;
  • A static property CANNOT be accessed via an object instance variable using the -> operator.
  • Static methods are methods defined in a class that are at the class-level and are NOT associated with particular instances of a class. They are declared with the static keyword:
    public static function add($op1, $op2) {…
  • Static methods CANNOT use the $this variable within their definitions.
  • Non-static methods are referred to as instance methods.
  • Static methods are called using the scope resolution operator (externally using the class name, and internally using the self keyword):
    • Externally: Person::getClassName()
    • Internally: self::getClassName()
  • A class constant is a constant defined within a class definition that is specific to that class. They are defined using the const keyword:
    const PI = 3.14;
  • They are accessed using the scope resolution operator (with no $ prepending their name):
    • Externally: Math::PI
    • Internally: self::PI
  • Additional Resources:

Classes vs. Objects

Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.

Advanced PHP Training with MySQL