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

Object Constructors

  • A constructor is a special object method that gets called automatically each time a new instance of a class is instantiated.
  • Constructors are used to perform any initialization tasks that need to be done before an object is ready to be used, such as providing default values for all of an object’s properties.
  • In PHP 5, constructors are known as magic methods and must be named __construct(). They are defined within a class definition just like any other object method.
  • Arguments are provided to an object’s constructor method by specifying them between the parentheses following the class name when an object is created using the new keyword:
    $person1 = new Person(‘Joe’, ‘Smith’);
  • A class is not required to have a constructor method.
  • Unlike other programming languages, only one constructor method can be defined per PHP class.
  • Additional Resources:

Object Constructors

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