Header Ads

PHP OOP Terms Explained

   





  1. Class: Classes are the blueprints for PHP objects.
  2. Class contains both data variables and functions.
  3. Property: Variable inside a class called property.
  4. Method: Function inside a class called method.
  5. Methods are used to manipulate its own data.
  6. $this:$this” is one kind of built in variable which indicates own object.
  7. $this is used to access properties and methods of own class.
  8. You have to call a class using include or require where you use the class.
  9. Such as: If your class name is “Person.php”, you have to call like
          <?  include (“Person.php ”); ?>
       Or,
          <?  require (“Person.php ”); ?>

        Then we have to instantiate our class, like
$person = new Person();

  • Some other points

  • Access Modifiers: Public, Protected, Private known as access modifiers.
  • Instantiating: Instantiate means creating our object to use them.
  • We will use $person variable to control the class person.
  • We have to use arrow (->) operator to access methods and properties.
  •  We have to use “new” keyword to create an object from a class. It is also called “Instantiating of a class”


No comments

Search This Blog

Theme images by Ollustrator. Powered by Blogger.