PHP OOP Terms Explained
|
- Class: Classes are the blueprints for PHP objects.
- Class contains both data variables and functions.
- Property: Variable inside a class called property.
- Method: Function inside a class called method.
- Methods are used to manipulate its own data.
- $this: “$this” is one kind of built in variable which indicates own object.
- $this is used to access properties and methods of own class.
- You have to call a class using include or require where you use the class.
- 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