SlideShare a Scribd company logo
1 of 35
  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 DeveloperNyros 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 phpCPD INDIA
 
Object Oriented Programming in PHP
Object Oriented Programming in PHPObject Oriented Programming in PHP
Object Oriented Programming in PHPLorna Mitchell
 
Introduction to OOP with PHP
Introduction to OOP with PHPIntroduction to OOP with PHP
Introduction to OOP with PHPMichael Peacock
 
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 PHP5Jason Austin
 
Intermediate OOP in PHP
Intermediate OOP in PHPIntermediate OOP in PHP
Intermediate OOP in PHPDavid Stockton
 
Intro to OOP PHP and Github
Intro to OOP PHP and GithubIntro to OOP PHP and Github
Intro to OOP PHP and GithubJo Erik San Jose
 
Introduction to PHP OOP
Introduction to PHP OOPIntroduction to PHP OOP
Introduction to PHP OOPfakhrul 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 #burningkeyboardsDenis 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 PHPVibrant 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 PythonSujith Kumar
 
Only oop
Only oopOnly oop
Only oopanitarooge
 
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 BORSANIYAMaulik Borsaniya
 

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 PHPRick 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 phpherat university
 
Basic Oops concept of PHP
Basic Oops concept of PHPBasic Oops concept of PHP
Basic Oops concept of PHPRohan Sharma
 
Advance enginering mathematics
Advance enginering mathematicsAdvance enginering mathematics
Advance enginering mathematicsUttam Trasadiya
 
Oop concepts
Oop conceptsOop concepts
Oop conceptsRitu Mangla
 
Beginning OOP in PHP
Beginning OOP in PHPBeginning OOP in PHP
Beginning OOP in PHPDavid Stockton
 
BUILDING WEBSITES ON WORDPRESS
BUILDING WEBSITES ON WORDPRESSBUILDING WEBSITES ON WORDPRESS
BUILDING WEBSITES ON WORDPRESSPRINCE 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 PHPAman Soni
 
Zend Php Certification Study Guide
Zend Php Certification Study GuideZend Php Certification Study Guide
Zend Php Certification Study GuideKamalika Guha Roy
 
Web School - School Management System
Web School - School Management SystemWeb School - School Management System
Web School - School Management Systemaju a s
 
Useful functions for arrays in php
Useful functions for arrays in phpUseful functions for arrays in php
Useful functions for arrays in phpChetan 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 materialDeepak Solanki
 
06-classes.ppt (copy).pptx
06-classes.ppt (copy).pptx06-classes.ppt (copy).pptx
06-classes.ppt (copy).pptxThắng It
 
Objects, Testing, and Responsibility
Objects, Testing, and ResponsibilityObjects, Testing, and Responsibility
Objects, Testing, and Responsibilitymachuga
 
Object Oriented Programming in PHP
Object Oriented Programming  in PHPObject Oriented Programming  in PHP
Object Oriented Programming in PHPwahidullah 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 5Stephan Schmidt
 
PHP OOP Lecture - 04.pptx
PHP OOP Lecture - 04.pptxPHP OOP Lecture - 04.pptx
PHP OOP Lecture - 04.pptxAtikur 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 CollegeDhivyaa C.R
 
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 PHPAlena 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
 
Oops concept in php
Oops concept in phpOops concept in php
Oops concept in phpselvabalaji k
 
14 Defining classes
14 Defining classes14 Defining classes
14 Defining classesmaznabili
 

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
 
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
 
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
 
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

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

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vĂĄzquez
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 

Recently uploaded (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 

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.