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 Methods

  • Classes can define functions, known as object methods, that instances of the class can execute.
  • An object method is defined within the curly braces of a class definition using the same syntax used when creating user-defined functions.
  • Object methods are called using the arrow operator ->. An object variable is followed by ->, the name of the method, and a set of parentheses, which can optionally include any arguments to be passed to the object method:
    $person1 = new Person();
    $person1->hello(); // object method requiring no arguments
    $person1->helloWithArg($arg1); // object method requiring arguments
  • Object methods can return values just like user-defined functions.
  • $this is a special variable in PHP that is used within a class’s methods to refer to the current instance of a class.
  • A getter method retrieves the value of an object’s property.
  • A setter method sets the value of an object’s property.
  • An object method’s return value can be output within double-quoted strings using curly brace syntax:
    $person1 = new Person();
    $person1->setFirstName(‘Joe’);
    echo “First: {$person1->getFirstName()}”;
  • Object methods can call other object methods of the same object instance by using the $this variable.

Object Methods

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