SlideShare a Scribd company logo
  PHP Classes  and  Object Orientation
Revision HIstory # Version Date Rationale for change  Change Description 1 1.0 26-Feb-2008 Initial Version 2
Revision HIstory Document Name Training Material Document Code QMS-TEM-OT 08 Version  1.0 Date 26-Feb-2008 Created By Ms. Padmavathy  Reviewed BY SPG Approved By Mr. Vijay
Agenda ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Reminder… a function ,[object Object],[object Object],[object Object],[object Object],[object Object]
Conceptually, what does a function represent?  … give the function something (arguments), it does something with them, and then returns a result… Action  or  Method
What is a  class ? Conceptually, a class represents an  object , with associated methods and variables
Class Definition <?php class  dog { public  $name; public function  bark() { echo   ‘Woof!’ ; } }  ?> An example class definition for a dog. The dog object has a single attribute, the name, and can perform the action of barking.
Class Definition <?php class  dog { public  $name; public function  bark() { echo  ‘Woof!’ ; } }  ?> class  dog { Define the  name  of the class.
Class Definition <?php class  dog { public  $name; public function  bark() { echo   ‘Woof!’ ; } }  ?> public  $name; Define an object attribute (variable), the dog’s name.
Class Definition <?php class  dog { public  $name; public function  bark() { echo   ‘Woof!’ ; } }  ?> public function  bark() { echo   ‘Woof!’ ; } Define an object action (function), the dog’s bark.
Class Defintion Similar to defining a function.. The definition  does not do anything   by itself . It is a blueprint, or description, of an object. To do something, you need to  use  the class…
Class Usage <?php require ( ‘dog.class.php’ ); $puppy =  new  dog(); $puppy->name =  ‘Rover’ ; echo  “ {$puppy->name}  says ” ; $puppy->bark(); ?>
Class Usage <?php require ( ‘dog.class.php’ ); $puppy =  new  dog(); $puppy->name =  ‘Rover’ ; echo  “ {$puppy->name}  says ” ; $puppy->bark(); ?> require ( ‘dog.class.php’ ); Include the class definition
Class Usage <?php require ( ‘dog.class.php’ ); $puppy =  new  dog(); $puppy->name =  ‘Rover’ ; echo  “ {$puppy->name}  says ” ; $puppy->bark(); ?> $puppy =  new  dog(); Create a new  instance  of the class.
Class Usage <?php require ( ‘dog.class.php’ ); $puppy =  new  dog(); $puppy->name =  ‘Rover’ ; echo  “ {$puppy->name}  says ” ; $puppy->bark(); ?> $puppy->name =  ‘Rover’ ; Set the name variable  of this instance  to ‘Rover’.
Class Usage <?php require ( ‘dog.class.php’ ); $puppy =  new  dog(); $puppy->name =  ‘Rover’ ; echo  “ {$puppy->name}  says ” ; $puppy->bark(); ?> echo  “ {$puppy->name}  says ” ; Use the name variable of this instance in an echo statement..
Class Usage <?php require ( ‘dog.class.php’ ); $puppy =  new  dog(); $puppy->name =  ‘Rover’ ; echo  “ {$puppy->name}  says ” ; $puppy->bark(); ?> $puppy->bark(); Use the dog object bark method.
One dollar and one only… $puppy->name =  ‘Rover’ ; The most common mistake is to use more than one dollar sign when accessing variables. The following means something entirely different.. $puppy->$name =  ‘Rover’ ;
Using attributes within the class.. ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Constructor methods ,[object Object],[object Object],[object Object]
Constructor Example <?php class  dog { public  $name; public function   __construct ($nametext) { $this->name = $nametext; }   public function  bark() { echo  ‘Woof!’; } }  ?>
Constructor Example <?php … $puppy =  new  dog( ‘Rover’ ); … ?> Constructor arguments are passed during the instantiation of the object.
Class Scope ,[object Object],[object Object]
Inheritance ,[object Object],dog poodle alsatian parent children
Inheritance ,[object Object],[object Object]
Inheritance example The American Kennel Club (AKC) recognizes three sizes of poodle -  Standard, Miniature, and Toy …  class   poodle   extends  dog { public  $type; public   function  set_type($height) { if  ($height<10) {  $this->type =  ‘Toy’ ; }  elseif  ($height>15) { $this->type =  ‘Standard’ ; }  else  { $this->type =  ‘Miniature’ ; } } }
Inheritance example The American Kennel Club (AKC) recognizes three sizes of poodle -  Standard, Miniature, and Toy…  class  poodle   extends  dog { public  $type; public function  set_type($height) { if  ($height<10) {  $this->type =  ‘Toy’ ;   }  elseif  ($height>15) { $this->type =  ‘Standard’ ; }  else  { $this->type =  ‘Miniature’ ;   } } } class  poodle  extends  dog { Note the use of the  extends  keyword to indicate that the poodle class is a child of the dog class…
Inheritance example … $puppy =  new  poodle( ‘Oscar’ ); $puppy->set_type(12);  // 12 inches high! echo   “Poodle is called  {$puppy->name} , ” ; echo   “of type  {$puppy->type} , saying “ ; echo  $puppy->bark(); …
… a poodle will always ‘Yip!’ ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Child Constructors? ,[object Object],[object Object],[object Object],[object Object]
Deleting objects ,[object Object],[object Object]
There is a lot more… ,[object Object],[object Object]
PHP4 vs. PHP5 ,[object Object],[object Object],[object Object],[object Object]
Thank you

More Related Content

What's hot

Oops in PHP By Nyros Developer
Oops in PHP By Nyros DeveloperOops in PHP By Nyros Developer
Oops in PHP By Nyros Developer
Nyros Technologies
 
Oop in-php
Oop in-phpOop in-php
Oop in-phpRajesh S
 
Oops concepts in php
Oops concepts in phpOops concepts in php
Oops concepts in php
CPD INDIA
 
OOP in PHP
OOP in PHPOOP in PHP
OOP in PHP
Alena Holligan
 
Object Oriented Programming in PHP
Object Oriented Programming in PHPObject Oriented Programming in PHP
Object Oriented Programming in PHP
Lorna Mitchell
 
Introduction to OOP with PHP
Introduction to OOP with PHPIntroduction to OOP with PHP
Introduction to OOP with PHPMichael Peacock
 
Oops in php
Oops in phpOops in php
Oops in php
sanjay joshi
 
A Gentle Introduction To Object Oriented Php
A Gentle Introduction To Object Oriented PhpA Gentle Introduction To Object Oriented Php
A Gentle Introduction To Object Oriented PhpMichael Girouard
 
Object Oriented PHP5
Object Oriented PHP5Object Oriented PHP5
Object Oriented PHP5
Jason Austin
 
PHP- Introduction to Object Oriented PHP
PHP-  Introduction to Object Oriented PHPPHP-  Introduction to Object Oriented PHP
PHP- Introduction to Object Oriented PHP
Vibrant Technologies & Computers
 
Intermediate OOP in PHP
Intermediate OOP in PHPIntermediate OOP in PHP
Intermediate OOP in PHP
David Stockton
 
Intro to OOP PHP and Github
Intro to OOP PHP and GithubIntro to OOP PHP and Github
Intro to OOP PHP and Github
Jo Erik San Jose
 
Introduction to PHP OOP
Introduction to PHP OOPIntroduction to PHP OOP
Introduction to PHP OOP
fakhrul hasan
 
09 Object Oriented Programming in PHP #burningkeyboards
09 Object Oriented Programming in PHP #burningkeyboards09 Object Oriented Programming in PHP #burningkeyboards
09 Object Oriented Programming in PHP #burningkeyboards
Denis Ristic
 
PHP - Introduction to Object Oriented Programming with PHP
PHP -  Introduction to  Object Oriented Programming with PHPPHP -  Introduction to  Object Oriented Programming with PHP
PHP - Introduction to Object Oriented Programming with PHP
Vibrant Technologies & Computers
 
Basics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonBasics of Object Oriented Programming in Python
Basics of Object Oriented Programming in Python
Sujith Kumar
 
Only oop
Only oopOnly oop
Only oop
anitarooge
 
PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYA
PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYAPYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYA
PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYA
Maulik Borsaniya
 
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
 

What's hot (20)

Oops in PHP By Nyros Developer
Oops in PHP By Nyros DeveloperOops in PHP By Nyros Developer
Oops in PHP By Nyros Developer
 
Oop in-php
Oop in-phpOop in-php
Oop in-php
 
Oops concepts in php
Oops concepts in phpOops concepts in php
Oops concepts in php
 
OOP in PHP
OOP in PHPOOP in PHP
OOP in PHP
 
Object Oriented Programming in PHP
Object Oriented Programming in PHPObject Oriented Programming in PHP
Object Oriented Programming in PHP
 
Introduction to OOP with PHP
Introduction to OOP with PHPIntroduction to OOP with PHP
Introduction to OOP with PHP
 
Oops in php
Oops in phpOops in php
Oops in php
 
A Gentle Introduction To Object Oriented Php
A Gentle Introduction To Object Oriented PhpA Gentle Introduction To Object Oriented Php
A Gentle Introduction To Object Oriented Php
 
Object Oriented PHP5
Object Oriented PHP5Object Oriented PHP5
Object Oriented PHP5
 
PHP- Introduction to Object Oriented PHP
PHP-  Introduction to Object Oriented PHPPHP-  Introduction to Object Oriented PHP
PHP- Introduction to Object Oriented PHP
 
Intermediate OOP in PHP
Intermediate OOP in PHPIntermediate OOP in PHP
Intermediate OOP in PHP
 
Intro to OOP PHP and Github
Intro to OOP PHP and GithubIntro to OOP PHP and Github
Intro to OOP PHP and Github
 
Introduction to PHP OOP
Introduction to PHP OOPIntroduction to PHP OOP
Introduction to PHP OOP
 
09 Object Oriented Programming in PHP #burningkeyboards
09 Object Oriented Programming in PHP #burningkeyboards09 Object Oriented Programming in PHP #burningkeyboards
09 Object Oriented Programming in PHP #burningkeyboards
 
PHP - Introduction to Object Oriented Programming with PHP
PHP -  Introduction to  Object Oriented Programming with PHPPHP -  Introduction to  Object Oriented Programming with PHP
PHP - Introduction to Object Oriented Programming with PHP
 
Basics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonBasics of Object Oriented Programming in Python
Basics of Object Oriented Programming in Python
 
Introduction to php oop
Introduction to php oopIntroduction to php oop
Introduction to php oop
 
Only oop
Only oopOnly oop
Only oop
 
PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYA
PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYAPYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYA
PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYA
 
OOPS Characteristics (With Examples in PHP)
OOPS Characteristics (With Examples in PHP)OOPS Characteristics (With Examples in PHP)
OOPS Characteristics (With Examples in PHP)
 

Viewers also liked

Beginners Guide to Object Orientation in PHP
Beginners Guide to Object Orientation in PHPBeginners Guide to Object Orientation in PHP
Beginners Guide to Object Orientation in PHP
Rick Ogden
 
Login and Registration form using oop in php
Login and Registration form using oop in phpLogin and Registration form using oop in php
Login and Registration form using oop in php
herat university
 
Basic Oops concept of PHP
Basic Oops concept of PHPBasic Oops concept of PHP
Basic Oops concept of PHP
Rohan Sharma
 
General OOP Concepts
General OOP ConceptsGeneral OOP Concepts
General OOP Concepts
Praveen M Jigajinni
 
Advance enginering mathematics
Advance enginering mathematicsAdvance enginering mathematics
Advance enginering mathematics
Uttam Trasadiya
 
Oop concepts
Oop conceptsOop concepts
Oop concepts
Ritu Mangla
 
Beginning OOP in PHP
Beginning OOP in PHPBeginning OOP in PHP
Beginning OOP in PHP
David Stockton
 
BUILDING WEBSITES ON WORDPRESS
BUILDING WEBSITES ON WORDPRESSBUILDING WEBSITES ON WORDPRESS
BUILDING WEBSITES ON WORDPRESS
PRINCE KUMAR
 
Dropr - The Message Queue project for PHP
Dropr - The Message Queue project for PHPDropr - The Message Queue project for PHP
Dropr - The Message Queue project for PHPelliando dias
 
Ejobportal project ppt on php my_sql
Ejobportal project ppt on php my_sqlEjobportal project ppt on php my_sql
Ejobportal project ppt on php my_sqlprabhat kumar
 
Lan chatting and file transfer Project on PHP
Lan chatting and file transfer Project on PHPLan chatting and file transfer Project on PHP
Lan chatting and file transfer Project on PHP
Aman Soni
 
Zend Php Certification Study Guide
Zend Php Certification Study GuideZend Php Certification Study Guide
Zend Php Certification Study Guide
Kamalika Guha Roy
 
PHP based School ERP
PHP based School ERPPHP based School ERP
PHP based School ERP
Coderobotics Studio
 
Web School - School Management System
Web School - School Management SystemWeb School - School Management System
Web School - School Management System
aju a s
 
Useful functions for arrays in php
Useful functions for arrays in phpUseful functions for arrays in php
Useful functions for arrays in php
Chetan Patel
 
Php login system with admin features evolt
Php login system with admin features   evoltPhp login system with admin features   evolt
Php login system with admin features evoltGIMT
 

Viewers also liked (18)

Beginners Guide to Object Orientation in PHP
Beginners Guide to Object Orientation in PHPBeginners Guide to Object Orientation in PHP
Beginners Guide to Object Orientation in PHP
 
Login and Registration form using oop in php
Login and Registration form using oop in phpLogin and Registration form using oop in php
Login and Registration form using oop in php
 
Basic Oops concept of PHP
Basic Oops concept of PHPBasic Oops concept of PHP
Basic Oops concept of PHP
 
General OOP Concepts
General OOP ConceptsGeneral OOP Concepts
General OOP Concepts
 
Advance enginering mathematics
Advance enginering mathematicsAdvance enginering mathematics
Advance enginering mathematics
 
Oop concepts
Oop conceptsOop concepts
Oop concepts
 
Oop concepts
Oop conceptsOop concepts
Oop concepts
 
Beginning OOP in PHP
Beginning OOP in PHPBeginning OOP in PHP
Beginning OOP in PHP
 
BUILDING WEBSITES ON WORDPRESS
BUILDING WEBSITES ON WORDPRESSBUILDING WEBSITES ON WORDPRESS
BUILDING WEBSITES ON WORDPRESS
 
Dropr - The Message Queue project for PHP
Dropr - The Message Queue project for PHPDropr - The Message Queue project for PHP
Dropr - The Message Queue project for PHP
 
Ejobportal project ppt on php my_sql
Ejobportal project ppt on php my_sqlEjobportal project ppt on php my_sql
Ejobportal project ppt on php my_sql
 
Lan chatting and file transfer Project on PHP
Lan chatting and file transfer Project on PHPLan chatting and file transfer Project on PHP
Lan chatting and file transfer Project on PHP
 
Zend Php Certification Study Guide
Zend Php Certification Study GuideZend Php Certification Study Guide
Zend Php Certification Study Guide
 
PHP based School ERP
PHP based School ERPPHP based School ERP
PHP based School ERP
 
Web School - School Management System
Web School - School Management SystemWeb School - School Management System
Web School - School Management System
 
Useful functions for arrays in php
Useful functions for arrays in phpUseful functions for arrays in php
Useful functions for arrays in php
 
Php login system with admin features evolt
Php login system with admin features   evoltPhp login system with admin features   evolt
Php login system with admin features evolt
 
General OOP concept [by-Digvijay]
General OOP concept [by-Digvijay]General OOP concept [by-Digvijay]
General OOP concept [by-Digvijay]
 

Similar to PHP Classes and OOPS Concept

Oops implemetation material
Oops implemetation materialOops implemetation material
Oops implemetation material
Deepak Solanki
 
06-classes.ppt (copy).pptx
06-classes.ppt (copy).pptx06-classes.ppt (copy).pptx
06-classes.ppt (copy).pptx
Thắng It
 
SQL Devlopment for 10 ppt
SQL Devlopment for 10 pptSQL Devlopment for 10 ppt
SQL Devlopment for 10 ppt
Tanay Kishore Mishra
 
Ch8(oop)
Ch8(oop)Ch8(oop)
Ch8(oop)
Chhom Karath
 
Objects, Testing, and Responsibility
Objects, Testing, and ResponsibilityObjects, Testing, and Responsibility
Objects, Testing, and Responsibility
machuga
 
Object Oriented Programming in PHP
Object Oriented Programming  in PHPObject Oriented Programming  in PHP
Object Oriented Programming in PHP
wahidullah mudaser
 
Object-Oriented Programming with PHP (part 1)
Object-Oriented Programming with PHP (part 1)Object-Oriented Programming with PHP (part 1)
Object-Oriented Programming with PHP (part 1)
Bozhidar Boshnakov
 
Go OO! - Real-life Design Patterns in PHP 5
Go OO! - Real-life Design Patterns in PHP 5Go OO! - Real-life Design Patterns in PHP 5
Go OO! - Real-life Design Patterns in PHP 5
Stephan Schmidt
 
Oops in php
Oops in phpOops in php
PHP OOP Lecture - 04.pptx
PHP OOP Lecture - 04.pptxPHP OOP Lecture - 04.pptx
PHP OOP Lecture - 04.pptx
Atikur Rahman
 
Object Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering College
Object Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering CollegeObject Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering College
Object Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering College
Dhivyaa C.R
 
UNIT III (8).pptx
UNIT III (8).pptxUNIT III (8).pptx
UNIT III (8).pptx
DrDhivyaaCRAssistant
 
UNIT III (8).pptx
UNIT III (8).pptxUNIT III (8).pptx
UNIT III (8).pptx
DrDhivyaaCRAssistant
 
Demystifying Object-Oriented Programming - Lone Star PHP
Demystifying Object-Oriented Programming - Lone Star PHPDemystifying Object-Oriented Programming - Lone Star PHP
Demystifying Object-Oriented Programming - Lone Star PHP
Alena Holligan
 
OOP is more than Cars and Dogs
OOP is more than Cars and Dogs OOP is more than Cars and Dogs
OOP is more than Cars and Dogs
Chris Tankersley
 
SPL: The Missing Link in Development
SPL: The Missing Link in DevelopmentSPL: The Missing Link in Development
SPL: The Missing Link in Developmentjsmith92
 
14 Defining classes
14 Defining classes14 Defining classes
14 Defining classes
maznabili
 

Similar to PHP Classes and OOPS Concept (20)

10 classes
10 classes10 classes
10 classes
 
Oops implemetation material
Oops implemetation materialOops implemetation material
Oops implemetation material
 
06-classes.ppt (copy).pptx
06-classes.ppt (copy).pptx06-classes.ppt (copy).pptx
06-classes.ppt (copy).pptx
 
SQL Devlopment for 10 ppt
SQL Devlopment for 10 pptSQL Devlopment for 10 ppt
SQL Devlopment for 10 ppt
 
OOP
OOPOOP
OOP
 
Ch8(oop)
Ch8(oop)Ch8(oop)
Ch8(oop)
 
Objects, Testing, and Responsibility
Objects, Testing, and ResponsibilityObjects, Testing, and Responsibility
Objects, Testing, and Responsibility
 
Object Oriented Programming in PHP
Object Oriented Programming  in PHPObject Oriented Programming  in PHP
Object Oriented Programming in PHP
 
Object-Oriented Programming with PHP (part 1)
Object-Oriented Programming with PHP (part 1)Object-Oriented Programming with PHP (part 1)
Object-Oriented Programming with PHP (part 1)
 
Go OO! - Real-life Design Patterns in PHP 5
Go OO! - Real-life Design Patterns in PHP 5Go OO! - Real-life Design Patterns in PHP 5
Go OO! - Real-life Design Patterns in PHP 5
 
Oops in php
Oops in phpOops in php
Oops in php
 
PHP OOP Lecture - 04.pptx
PHP OOP Lecture - 04.pptxPHP OOP Lecture - 04.pptx
PHP OOP Lecture - 04.pptx
 
Object Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering College
Object Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering CollegeObject Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering College
Object Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering College
 
UNIT III (8).pptx
UNIT III (8).pptxUNIT III (8).pptx
UNIT III (8).pptx
 
UNIT III (8).pptx
UNIT III (8).pptxUNIT III (8).pptx
UNIT III (8).pptx
 
Demystifying Object-Oriented Programming - Lone Star PHP
Demystifying Object-Oriented Programming - Lone Star PHPDemystifying Object-Oriented Programming - Lone Star PHP
Demystifying Object-Oriented Programming - Lone Star PHP
 
OOP is more than Cars and Dogs
OOP is more than Cars and Dogs OOP is more than Cars and Dogs
OOP is more than Cars and Dogs
 
SPL: The Missing Link in Development
SPL: The Missing Link in DevelopmentSPL: The Missing Link in Development
SPL: The Missing Link in Development
 
Oops concept in php
Oops concept in phpOops concept in php
Oops concept in php
 
14 Defining classes
14 Defining classes14 Defining classes
14 Defining classes
 

More from Dot Com Infoway - Custom Software, Mobile, Web Application Development and Digital Marketing Company

The Future of Web Apps_ Trends, Ideas, and Insights
The Future of Web Apps_ Trends, Ideas, and InsightsThe Future of Web Apps_ Trends, Ideas, and Insights
The Future of Performance Marketing: Key Trends Shaping 2024
The Future of Performance Marketing: Key Trends Shaping 2024The Future of Performance Marketing: Key Trends Shaping 2024
Aso in numbers [Infographic]
Aso in numbers [Infographic]Aso in numbers [Infographic]
How to turn the challenge of covid 19 into a digitalzation opportunity
How to turn the challenge of covid 19 into a digitalzation opportunity How to turn the challenge of covid 19 into a digitalzation opportunity
How to turn the challenge of covid 19 into a digitalzation opportunity
Dot Com Infoway - Custom Software, Mobile, Web Application Development and Digital Marketing Company
 
How Much Does It Cost To Build a Start-up?
How Much Does It Cost To Build a Start-up?How Much Does It Cost To Build a Start-up?
DCI - Free Seo Tools
DCI - Free Seo ToolsDCI - Free Seo Tools
How to Grow Your Business to 10X by Building a Mobile App?
How to Grow Your Business to 10X by Building a Mobile App?How to Grow Your Business to 10X by Building a Mobile App?
ICO Marketing Guide
ICO Marketing GuideICO Marketing Guide
Webinar on "Measure & Optimize ROI with Influencer Marketing"
Webinar on "Measure & Optimize ROI with Influencer Marketing"Webinar on "Measure & Optimize ROI with Influencer Marketing"
Webinar on "Mobile App Marketing KPIs and Metrics"
Webinar on "Mobile App Marketing KPIs and Metrics"Webinar on "Mobile App Marketing KPIs and Metrics"
Webinar - Influence of Mobile Apps in the Growth of IoT
Webinar - Influence of Mobile Apps in the Growth of IoTWebinar - Influence of Mobile Apps in the Growth of IoT
Google SEO Ranking Factors 2017
Google SEO Ranking Factors 2017Google SEO Ranking Factors 2017
Take Your App to the Top This Holiday Season
Take Your App to the Top This Holiday SeasonTake Your App to the Top This Holiday Season
Webinar - Effective Tactics to Grow Loyal Users for Your App
Webinar - Effective Tactics to Grow Loyal Users for Your AppWebinar - Effective Tactics to Grow Loyal Users for Your App
Webinar - Why SEO Marketing is Important for Startup
Webinar - Why SEO Marketing is Important for StartupWebinar - Why SEO Marketing is Important for Startup
Top Web Technology Trends to Watch in 2016
Top Web Technology Trends to Watch in 2016Top Web Technology Trends to Watch in 2016
6 Strategies to Drive Mobile App Engagement
6 Strategies to Drive Mobile App Engagement6 Strategies to Drive Mobile App Engagement
Social Media Statistics And Trends
Social Media Statistics And TrendsSocial Media Statistics And Trends
Importance of Visual Content Marketing
Importance of Visual Content MarketingImportance of Visual Content Marketing
How to Plan for Successful App Launch
How to Plan for Successful App LaunchHow to Plan for Successful App Launch

More from Dot Com Infoway - Custom Software, Mobile, Web Application Development and Digital Marketing Company (20)

The Future of Web Apps_ Trends, Ideas, and Insights
The Future of Web Apps_ Trends, Ideas, and InsightsThe Future of Web Apps_ Trends, Ideas, and Insights
The Future of Web Apps_ Trends, Ideas, and Insights
 
The Future of Performance Marketing: Key Trends Shaping 2024
The Future of Performance Marketing: Key Trends Shaping 2024The Future of Performance Marketing: Key Trends Shaping 2024
The Future of Performance Marketing: Key Trends Shaping 2024
 
Aso in numbers [Infographic]
Aso in numbers [Infographic]Aso in numbers [Infographic]
Aso in numbers [Infographic]
 
How to turn the challenge of covid 19 into a digitalzation opportunity
How to turn the challenge of covid 19 into a digitalzation opportunity How to turn the challenge of covid 19 into a digitalzation opportunity
How to turn the challenge of covid 19 into a digitalzation opportunity
 
How Much Does It Cost To Build a Start-up?
How Much Does It Cost To Build a Start-up?How Much Does It Cost To Build a Start-up?
How Much Does It Cost To Build a Start-up?
 
DCI - Free Seo Tools
DCI - Free Seo ToolsDCI - Free Seo Tools
DCI - Free Seo Tools
 
How to Grow Your Business to 10X by Building a Mobile App?
How to Grow Your Business to 10X by Building a Mobile App?How to Grow Your Business to 10X by Building a Mobile App?
How to Grow Your Business to 10X by Building a Mobile App?
 
ICO Marketing Guide
ICO Marketing GuideICO Marketing Guide
ICO Marketing Guide
 
Webinar on "Measure & Optimize ROI with Influencer Marketing"
Webinar on "Measure & Optimize ROI with Influencer Marketing"Webinar on "Measure & Optimize ROI with Influencer Marketing"
Webinar on "Measure & Optimize ROI with Influencer Marketing"
 
Webinar on "Mobile App Marketing KPIs and Metrics"
Webinar on "Mobile App Marketing KPIs and Metrics"Webinar on "Mobile App Marketing KPIs and Metrics"
Webinar on "Mobile App Marketing KPIs and Metrics"
 
Webinar - Influence of Mobile Apps in the Growth of IoT
Webinar - Influence of Mobile Apps in the Growth of IoTWebinar - Influence of Mobile Apps in the Growth of IoT
Webinar - Influence of Mobile Apps in the Growth of IoT
 
Google SEO Ranking Factors 2017
Google SEO Ranking Factors 2017Google SEO Ranking Factors 2017
Google SEO Ranking Factors 2017
 
Take Your App to the Top This Holiday Season
Take Your App to the Top This Holiday SeasonTake Your App to the Top This Holiday Season
Take Your App to the Top This Holiday Season
 
Webinar - Effective Tactics to Grow Loyal Users for Your App
Webinar - Effective Tactics to Grow Loyal Users for Your AppWebinar - Effective Tactics to Grow Loyal Users for Your App
Webinar - Effective Tactics to Grow Loyal Users for Your App
 
Webinar - Why SEO Marketing is Important for Startup
Webinar - Why SEO Marketing is Important for StartupWebinar - Why SEO Marketing is Important for Startup
Webinar - Why SEO Marketing is Important for Startup
 
Top Web Technology Trends to Watch in 2016
Top Web Technology Trends to Watch in 2016Top Web Technology Trends to Watch in 2016
Top Web Technology Trends to Watch in 2016
 
6 Strategies to Drive Mobile App Engagement
6 Strategies to Drive Mobile App Engagement6 Strategies to Drive Mobile App Engagement
6 Strategies to Drive Mobile App Engagement
 
Social Media Statistics And Trends
Social Media Statistics And TrendsSocial Media Statistics And Trends
Social Media Statistics And Trends
 
Importance of Visual Content Marketing
Importance of Visual Content MarketingImportance of Visual Content Marketing
Importance of Visual Content Marketing
 
How to Plan for Successful App Launch
How to Plan for Successful App LaunchHow to Plan for Successful App Launch
How to Plan for Successful App Launch
 

Recently uploaded

GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 

Recently uploaded (20)

GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 

PHP Classes and OOPS Concept

  • 1. PHP Classes and Object Orientation
  • 2. Revision HIstory # Version Date Rationale for change Change Description 1 1.0 26-Feb-2008 Initial Version 2
  • 3. Revision HIstory Document Name Training Material Document Code QMS-TEM-OT 08 Version 1.0 Date 26-Feb-2008 Created By Ms. Padmavathy Reviewed BY SPG Approved By Mr. Vijay
  • 4.
  • 5.
  • 6. Conceptually, what does a function represent? … give the function something (arguments), it does something with them, and then returns a result… Action or Method
  • 7. What is a class ? Conceptually, a class represents an object , with associated methods and variables
  • 8. Class Definition <?php class dog { public $name; public function bark() { echo ‘Woof!’ ; } } ?> An example class definition for a dog. The dog object has a single attribute, the name, and can perform the action of barking.
  • 9. Class Definition <?php class dog { public $name; public function bark() { echo ‘Woof!’ ; } } ?> class dog { Define the name of the class.
  • 10. Class Definition <?php class dog { public $name; public function bark() { echo ‘Woof!’ ; } } ?> public $name; Define an object attribute (variable), the dog’s name.
  • 11. Class Definition <?php class dog { public $name; public function bark() { echo ‘Woof!’ ; } } ?> public function bark() { echo ‘Woof!’ ; } Define an object action (function), the dog’s bark.
  • 12. Class Defintion Similar to defining a function.. The definition does not do anything by itself . It is a blueprint, or description, of an object. To do something, you need to use the class…
  • 13. Class Usage <?php require ( ‘dog.class.php’ ); $puppy = new dog(); $puppy->name = ‘Rover’ ; echo “ {$puppy->name} says ” ; $puppy->bark(); ?>
  • 14. Class Usage <?php require ( ‘dog.class.php’ ); $puppy = new dog(); $puppy->name = ‘Rover’ ; echo “ {$puppy->name} says ” ; $puppy->bark(); ?> require ( ‘dog.class.php’ ); Include the class definition
  • 15. Class Usage <?php require ( ‘dog.class.php’ ); $puppy = new dog(); $puppy->name = ‘Rover’ ; echo “ {$puppy->name} says ” ; $puppy->bark(); ?> $puppy = new dog(); Create a new instance of the class.
  • 16. Class Usage <?php require ( ‘dog.class.php’ ); $puppy = new dog(); $puppy->name = ‘Rover’ ; echo “ {$puppy->name} says ” ; $puppy->bark(); ?> $puppy->name = ‘Rover’ ; Set the name variable of this instance to ‘Rover’.
  • 17. Class Usage <?php require ( ‘dog.class.php’ ); $puppy = new dog(); $puppy->name = ‘Rover’ ; echo “ {$puppy->name} says ” ; $puppy->bark(); ?> echo “ {$puppy->name} says ” ; Use the name variable of this instance in an echo statement..
  • 18. Class Usage <?php require ( ‘dog.class.php’ ); $puppy = new dog(); $puppy->name = ‘Rover’ ; echo “ {$puppy->name} says ” ; $puppy->bark(); ?> $puppy->bark(); Use the dog object bark method.
  • 19. One dollar and one only… $puppy->name = ‘Rover’ ; The most common mistake is to use more than one dollar sign when accessing variables. The following means something entirely different.. $puppy->$name = ‘Rover’ ;
  • 20.
  • 21.
  • 22. Constructor Example <?php class dog { public $name; public function __construct ($nametext) { $this->name = $nametext; } public function bark() { echo ‘Woof!’; } } ?>
  • 23. Constructor Example <?php … $puppy = new dog( ‘Rover’ ); … ?> Constructor arguments are passed during the instantiation of the object.
  • 24.
  • 25.
  • 26.
  • 27. Inheritance example The American Kennel Club (AKC) recognizes three sizes of poodle -  Standard, Miniature, and Toy … class poodle extends dog { public $type; public function set_type($height) { if ($height<10) { $this->type = ‘Toy’ ; } elseif ($height>15) { $this->type = ‘Standard’ ; } else { $this->type = ‘Miniature’ ; } } }
  • 28. Inheritance example The American Kennel Club (AKC) recognizes three sizes of poodle -  Standard, Miniature, and Toy… class poodle extends dog { public $type; public function set_type($height) { if ($height<10) { $this->type = ‘Toy’ ; } elseif ($height>15) { $this->type = ‘Standard’ ; } else { $this->type = ‘Miniature’ ; } } } class poodle extends dog { Note the use of the extends keyword to indicate that the poodle class is a child of the dog class…
  • 29. Inheritance example … $puppy = new poodle( ‘Oscar’ ); $puppy->set_type(12); // 12 inches high! echo “Poodle is called {$puppy->name} , ” ; echo “of type {$puppy->type} , saying “ ; echo $puppy->bark(); …
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.