SlideShare a Scribd company logo
OOPs in PHP
http://rajvishwakarma15.blogspot.in/2014/01/oops-
abstraction-encapsulation.html
http://www.phpzag.com/overloading-and-overriding-
in-php/
Access Specifiers
OOps
$this
 $this is a special self-referencing
variable that is used to access
properties and methods from within
the class.
Visibility in PHP Classes
 Available Visibility in PHP Classes
 Access specifiers specify the level of access .
 There are 3 type of visibility available in php for
controlling your property or method.
 Public: Public method or variable can be accessible
from anywher. I mean from inside the class, out side the
class and in child(will dicuss in next chapter) class also.
 Private: Method or property with private visibility can
only be accessible inside the class. You can not access
private method or variable from outside of your class.
 Protected: Method or variable with protected visibility
can only be access in the derived class. Or in other
word in child class. Protected will be used in the
process of inheritance.
INHERITANCE
inheritance has three types, single, multiple and multi level inheritance. But, PHP
supports only single inheritance, where, only one class can be derived from single
parent class
PHP OOP does not allow multiple inheritance, it allow only multilevel
inheritance.
In simple word, subclass can not extend more than one super class.
But PHP allow hierarchical inheritance, Hierarchical inheritance means child
can get property of their parent and parent can get property of grand parent,
We can inherit parent class properties and function if and only if they have
public or protected access modifiers.
class grandParent
{
//Body of grand parent class
}
class parent extends grandParent
{
//Body Of parent class
}
class child extends parent
{
//Body of child class
}
, inheritance has three types, single, multiple and multi level inheritance.
But, PHP supports only single inheritance, where, only one class can be
derived from single parent class. Even though,
PHP is not supporting any other inheritance type except single
inheritance, we can simulate multiple inheritance by using PHP
interfaces.
Polymorphism
Polymorphism is derived from 2 greek
words: poly and morphs. The word "poly"
means many and "morphs" means forms. So
polymorphism means many forms.
Polymorphism means one name many forms. One
function behaves different forms.
Overloading Same method name with different signature,
since PHP doesn’t support method overloading concept
=> Overriding When same methods defined in parents and
child class with same signature i.e know as method overriding
STATIC
STATIC DATA MEMBERS
AND METHODS
To declare a static property using static keyword.
Static properties of class is a property which is directly accessible from class
with the help of :: (scope resolution operator).
class test
{
public static $a;//Static variable
}
test::$a = 5;
echo test::$a;
//-class test
{
static function abc($param1 , $param2)
{
echo "$param1 , $param2";
}
}
test::abc("ankur" , "techflirt");
$this self
Represents an instance of the class
or object
Represents a class
Always begin with dollar ($) sign Never begin with dollar($) sign
Is followed by the -> operator Is followed by the :: operator
The property name after the ->
operator does not take dollar ($)
sign, e.g., $this->property.
The property name after the ::
operator always take the dollar ($)
sign.
Non-static
variable
Static variable
These variable
should not be
preceded by any
static keyword
Example:
class A
{
int a;
}
These variables
are preceded by
static
keyword.Example
class A
{
static int b;
}

More Related Content

What's hot

Object Orinted Programing(OOP) concepts \
Object Orinted Programing(OOP) concepts \Object Orinted Programing(OOP) concepts \
Object Orinted Programing(OOP) concepts \
Pritom Chaki
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
Vineeta Garg
 
Inheritance
InheritanceInheritance
Inheritance
Padma Kannan
 
Top 10 java oops interview questions
Top 10 java oops interview questionsTop 10 java oops interview questions
Top 10 java oops interview questions
nishajj
 
Top 10 java_oops_interview_questions
Top 10 java_oops_interview_questionsTop 10 java_oops_interview_questions
Top 10 java_oops_interview_questions
nishajj
 
Single inheritance
Single inheritanceSingle inheritance
Single inheritance
Äkshäý M S
 
10 access control
10   access control10   access control
10 access control
dhrubo kayal
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance chapter-6-computer-science-with-c++ opt
Inheritance chapter-6-computer-science-with-c++ optInheritance chapter-6-computer-science-with-c++ opt
Inheritance chapter-6-computer-science-with-c++ opt
deepakskb2013
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
RAJ KUMAR
 
Inheritance
InheritanceInheritance
Inheritance
Aadhi Aadhithya
 
OOP Inheritance
OOP InheritanceOOP Inheritance
OOP Inheritance
Anastasia Jakubow
 
Inheritance
InheritanceInheritance
Inheritance
Munsif Ullah
 
Access controlaspecifier and visibilty modes
Access controlaspecifier and visibilty modesAccess controlaspecifier and visibilty modes
Access controlaspecifier and visibilty modes
Vinay Kumar
 
Java - Inheritance Concepts
Java - Inheritance ConceptsJava - Inheritance Concepts
Java - Inheritance Concepts
Victer Paul
 
Inheritance In Java
Inheritance In JavaInheritance In Java
Inheritance In Java
Darpan Chelani
 
inheritance c++
inheritance c++inheritance c++
inheritance c++
Muraleedhar Sundararajan
 

What's hot (17)

Object Orinted Programing(OOP) concepts \
Object Orinted Programing(OOP) concepts \Object Orinted Programing(OOP) concepts \
Object Orinted Programing(OOP) concepts \
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 
Inheritance
InheritanceInheritance
Inheritance
 
Top 10 java oops interview questions
Top 10 java oops interview questionsTop 10 java oops interview questions
Top 10 java oops interview questions
 
Top 10 java_oops_interview_questions
Top 10 java_oops_interview_questionsTop 10 java_oops_interview_questions
Top 10 java_oops_interview_questions
 
Single inheritance
Single inheritanceSingle inheritance
Single inheritance
 
10 access control
10   access control10   access control
10 access control
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
 
Inheritance chapter-6-computer-science-with-c++ opt
Inheritance chapter-6-computer-science-with-c++ optInheritance chapter-6-computer-science-with-c++ opt
Inheritance chapter-6-computer-science-with-c++ opt
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
 
Inheritance
InheritanceInheritance
Inheritance
 
OOP Inheritance
OOP InheritanceOOP Inheritance
OOP Inheritance
 
Inheritance
InheritanceInheritance
Inheritance
 
Access controlaspecifier and visibilty modes
Access controlaspecifier and visibilty modesAccess controlaspecifier and visibilty modes
Access controlaspecifier and visibilty modes
 
Java - Inheritance Concepts
Java - Inheritance ConceptsJava - Inheritance Concepts
Java - Inheritance Concepts
 
Inheritance In Java
Inheritance In JavaInheritance In Java
Inheritance In Java
 
inheritance c++
inheritance c++inheritance c++
inheritance c++
 

Similar to Oo ps

Inheritance in java
Inheritance in javaInheritance in java
Oops
OopsOops
OOPS Characteristics (With Examples in PHP)
OOPS Characteristics (With Examples in PHP)OOPS Characteristics (With Examples in PHP)
OOPS Characteristics (With Examples in PHP)
baabtra.com - No. 1 supplier of quality freshers
 
Object Oriented Programming - Polymorphism and Interfaces
Object Oriented Programming - Polymorphism and InterfacesObject Oriented Programming - Polymorphism and Interfaces
Object Oriented Programming - Polymorphism and Interfaces
Habtamu Wolde
 
Learn Polymorphism in Python with Examples.pdf
Learn Polymorphism in Python with Examples.pdfLearn Polymorphism in Python with Examples.pdf
Learn Polymorphism in Python with Examples.pdf
Datacademy.ai
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
HarshitaAshwani
 
Inheritance ppt
Inheritance pptInheritance ppt
Inheritance ppt
Nivegeetha
 
Java inheritance
Java inheritanceJava inheritance
Java inheritance
SmrutiShah9
 
Learn java objects inheritance-overriding-polymorphism
Learn java objects  inheritance-overriding-polymorphismLearn java objects  inheritance-overriding-polymorphism
Learn java objects inheritance-overriding-polymorphism
TOPS Technologies
 
Eo gaddis java_chapter_09_5e
Eo gaddis java_chapter_09_5eEo gaddis java_chapter_09_5e
Eo gaddis java_chapter_09_5e
Gina Bullock
 
Eo gaddis java_chapter_09_5e
Eo gaddis java_chapter_09_5eEo gaddis java_chapter_09_5e
Eo gaddis java_chapter_09_5e
Gina Bullock
 
Ayan Das_25300121057.pptx
Ayan Das_25300121057.pptxAyan Das_25300121057.pptx
Ayan Das_25300121057.pptx
Ayan974999
 
Python-Polymorphism.pptx
Python-Polymorphism.pptxPython-Polymorphism.pptx
Python-Polymorphism.pptx
Karudaiyar Ganapathy
 
Inheritance and Polymorphism
Inheritance and PolymorphismInheritance and Polymorphism
Inheritance and Polymorphism
KartikKapgate
 
4th_class.pdf
4th_class.pdf4th_class.pdf
4th_class.pdf
RumiHossain5
 
Inheritance VS Polymorphism.pptx
Inheritance VS Polymorphism.pptxInheritance VS Polymorphism.pptx
Inheritance VS Polymorphism.pptx
RajdeepSaha67
 
Inheritance in Java.pdf
Inheritance in Java.pdfInheritance in Java.pdf
Inheritance in Java.pdf
kumari36
 
Introduction to PHP OOP
Introduction to PHP OOPIntroduction to PHP OOP
Introduction to PHP OOP
fakhrul hasan
 
Inheritance
InheritanceInheritance
Top 10 java oops interview questions
Top 10 java oops interview questionsTop 10 java oops interview questions
Top 10 java oops interview questions
nishajj
 

Similar to Oo ps (20)

Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Oops
OopsOops
Oops
 
OOPS Characteristics (With Examples in PHP)
OOPS Characteristics (With Examples in PHP)OOPS Characteristics (With Examples in PHP)
OOPS Characteristics (With Examples in PHP)
 
Object Oriented Programming - Polymorphism and Interfaces
Object Oriented Programming - Polymorphism and InterfacesObject Oriented Programming - Polymorphism and Interfaces
Object Oriented Programming - Polymorphism and Interfaces
 
Learn Polymorphism in Python with Examples.pdf
Learn Polymorphism in Python with Examples.pdfLearn Polymorphism in Python with Examples.pdf
Learn Polymorphism in Python with Examples.pdf
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Inheritance ppt
Inheritance pptInheritance ppt
Inheritance ppt
 
Java inheritance
Java inheritanceJava inheritance
Java inheritance
 
Learn java objects inheritance-overriding-polymorphism
Learn java objects  inheritance-overriding-polymorphismLearn java objects  inheritance-overriding-polymorphism
Learn java objects inheritance-overriding-polymorphism
 
Eo gaddis java_chapter_09_5e
Eo gaddis java_chapter_09_5eEo gaddis java_chapter_09_5e
Eo gaddis java_chapter_09_5e
 
Eo gaddis java_chapter_09_5e
Eo gaddis java_chapter_09_5eEo gaddis java_chapter_09_5e
Eo gaddis java_chapter_09_5e
 
Ayan Das_25300121057.pptx
Ayan Das_25300121057.pptxAyan Das_25300121057.pptx
Ayan Das_25300121057.pptx
 
Python-Polymorphism.pptx
Python-Polymorphism.pptxPython-Polymorphism.pptx
Python-Polymorphism.pptx
 
Inheritance and Polymorphism
Inheritance and PolymorphismInheritance and Polymorphism
Inheritance and Polymorphism
 
4th_class.pdf
4th_class.pdf4th_class.pdf
4th_class.pdf
 
Inheritance VS Polymorphism.pptx
Inheritance VS Polymorphism.pptxInheritance VS Polymorphism.pptx
Inheritance VS Polymorphism.pptx
 
Inheritance in Java.pdf
Inheritance in Java.pdfInheritance in Java.pdf
Inheritance in Java.pdf
 
Introduction to PHP OOP
Introduction to PHP OOPIntroduction to PHP OOP
Introduction to PHP OOP
 
Inheritance
InheritanceInheritance
Inheritance
 
Top 10 java oops interview questions
Top 10 java oops interview questionsTop 10 java oops interview questions
Top 10 java oops interview questions
 

Recently uploaded

clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
sayalidalavi006
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 

Recently uploaded (20)

clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 

Oo ps

  • 3. $this  $this is a special self-referencing variable that is used to access properties and methods from within the class.
  • 4. Visibility in PHP Classes  Available Visibility in PHP Classes  Access specifiers specify the level of access .  There are 3 type of visibility available in php for controlling your property or method.  Public: Public method or variable can be accessible from anywher. I mean from inside the class, out side the class and in child(will dicuss in next chapter) class also.  Private: Method or property with private visibility can only be accessible inside the class. You can not access private method or variable from outside of your class.  Protected: Method or variable with protected visibility can only be access in the derived class. Or in other word in child class. Protected will be used in the process of inheritance.
  • 6. inheritance has three types, single, multiple and multi level inheritance. But, PHP supports only single inheritance, where, only one class can be derived from single parent class PHP OOP does not allow multiple inheritance, it allow only multilevel inheritance. In simple word, subclass can not extend more than one super class. But PHP allow hierarchical inheritance, Hierarchical inheritance means child can get property of their parent and parent can get property of grand parent, We can inherit parent class properties and function if and only if they have public or protected access modifiers.
  • 7. class grandParent { //Body of grand parent class } class parent extends grandParent { //Body Of parent class } class child extends parent { //Body of child class } , inheritance has three types, single, multiple and multi level inheritance. But, PHP supports only single inheritance, where, only one class can be derived from single parent class. Even though, PHP is not supporting any other inheritance type except single inheritance, we can simulate multiple inheritance by using PHP interfaces.
  • 8. Polymorphism Polymorphism is derived from 2 greek words: poly and morphs. The word "poly" means many and "morphs" means forms. So polymorphism means many forms. Polymorphism means one name many forms. One function behaves different forms.
  • 9. Overloading Same method name with different signature, since PHP doesn’t support method overloading concept => Overriding When same methods defined in parents and child class with same signature i.e know as method overriding
  • 11. To declare a static property using static keyword. Static properties of class is a property which is directly accessible from class with the help of :: (scope resolution operator). class test { public static $a;//Static variable } test::$a = 5; echo test::$a; //-class test { static function abc($param1 , $param2) { echo "$param1 , $param2"; } } test::abc("ankur" , "techflirt");
  • 12. $this self Represents an instance of the class or object Represents a class Always begin with dollar ($) sign Never begin with dollar($) sign Is followed by the -> operator Is followed by the :: operator The property name after the -> operator does not take dollar ($) sign, e.g., $this->property. The property name after the :: operator always take the dollar ($) sign.
  • 13. Non-static variable Static variable These variable should not be preceded by any static keyword Example: class A { int a; } These variables are preceded by static keyword.Example class A { static int b; }