SlideShare ist ein Scribd-Unternehmen logo
1 von 22
Introduction to Object
Oriented Programming
with PHP
Object Oriented ConceptObject Oriented Concept
 Classes, which are the "blueprints" for an object and are the
actual code that defines the properties and methods.
 Objects, which are running instances of a class and contain
all the internal data and state information needed for your
application to function.
 Encapsulation, which is the capability of an object to protect
access to its internal data
 Inheritance, which is the ability to define a class of one kind
as being a sub-type of a different kind of class (much the
same way a square is a kind of rectangle).
Creating ClassCreating Class
• Let's start with a simple example. Save the following
in a file called class.lat.php:
<?php
class Demo
{
}
?>
Adding MethodAdding Method
• The Demo class isn't particularly useful if it isn't able
to do anything, so let's look at how you can create
a method.
<?php
class Demo
{
function SayHello($name)
{
echo “Hello $name !”;
}
}
?>
Adding PropertiesAdding Properties
• Adding a property to your class is as easy as adding
a method.
<?php
class Demo
{
public $name;
function SayHello()
{
echo “Hello $this->$name !”;
}
}
?>
Object InstantiationObject Instantiation
• You can instantiate an object of type Demo like
this:
<?php
require_once('class.lat.php');
$objDemo = new Demo();
$objDemo->name = “Bayu”;
$objDemo->SayHallo();
?>
Protecting Access toProtecting Access to
Member VariablesMember Variables (1)(1) There are three different levels of visibility that a member variable or method
can have :
 Public
â–Ş members are accessible to any and all code
 Private
â–Ş members are only accessible to the class itself
 Protected
â–Ş members are available to the class itself, and to classes that inherit
from it
Public is the default visibility level for any member variables or functions
that do not explicitly set one, but it is good practice to always explicitly state
the visibility of all the members of the class.
Public is the default visibility level for any member variables or functions
that do not explicitly set one, but it is good practice to always explicitly state
the visibility of all the members of the class.
Protecting Access toProtecting Access to
Member VariablesMember Variables (2)(2)
• Try to change access level of property named
“name” to private of previous code.
• What the possible solution of this problem?
• Make the getter and setter function...
Always use get and set functions for your properties. Changes to business logic
and data validation requirements in the future will be much easier to
implement.
Always use get and set functions for your properties. Changes to business logic
and data validation requirements in the future will be much easier to
implement.
Class ConstantsClass Constants
 It is possible to define constant values on a per-
class basis remaining the same and
unchangeable.
 Constants differ from normal variables in that you
don't use the $ symbol to declare or use them
 The value must be a constant expression, not (for
example) a variable, a property, a result of a
mathematical operation, or a function call
Class Constants (cont.)Class Constants (cont.)
<?php
class MyClass
{
    const constant = 'constant value';
    function showConstant() {
        echo  self::constant . "n";
    }
}
echo MyClass::constant . "n";
?>
<?php
class MyClass
{
    const constant = 'constant value';
    function showConstant() {
        echo  self::constant . "n";
    }
}
echo MyClass::constant . "n";
?>
Static KeywordStatic Keyword
• Declaring class properties or methods as static
makes them accessible without needing an
instantiation of the class.
• A property declared as static can not be accessed
with an instantiated class object
ContructorContructor
• Constructor is the method that will be implemented when object has
been initiated
• Commonly, constructor is used to initialize the object
• Use function __construct to create constructor in PHP
<?php
class Demo
{
function __construct
{
}
}
?>
DestructorDestructor
• Destructor, is method that will be run when object is
ended
<?php
class Demo
{
function __destruct
{
}
}
?>
InheritanceInheritance
• There are many benefits of inheritance with PHP, the
most common is simplifying and reducing instances of
redundant code.
Inheritance (2)Inheritance (2)
class hewan
{
protected $jml_kaki;
protected $warna_kulit;
function __construct()
{
}
function berpindah()
{
echo "Saya berpindah";
}
function makan()
{
echo "Saya makan";
}
}
class hewan
{
protected $jml_kaki;
protected $warna_kulit;
function __construct()
{
}
function berpindah()
{
echo "Saya berpindah";
}
function makan()
{
echo "Saya makan";
}
}
Inherintace (3)Inherintace (3)
TugasTugas
Tugas (cont.)Tugas (cont.)
 Class product :
 name
 price
 discount
 Class CDMusic :
 artist
 Genre
 Class CDRack
 capacity
 model
Tugas (cont.)Tugas (cont.)
 CDMusic
 Menuruni name, price dan discount dari Product
 Price = price + 10%
 Ada penambahan 5% pada discount
 CDRack
 Menuruni name, price dan discount dari Product
 Price = price + 15%
 Tidak ada penambahan discount
 Buatlah code dalam PHP, serta simulasi untuk kasus
tersebut!
ThankThank You !!!You !!!
For More Information click below link:
Follow Us on:
http://vibranttechnologies.co.in/php-classes-in-
mumbai.html

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

jQuery
jQueryjQuery
jQuery
 
Database Connectivity in PHP
Database Connectivity in PHPDatabase Connectivity in PHP
Database Connectivity in PHP
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
Event In JavaScript
Event In JavaScriptEvent In JavaScript
Event In JavaScript
 
Java script
Java scriptJava script
Java script
 
PHP - Introduction to File Handling with PHP
PHP -  Introduction to  File Handling with PHPPHP -  Introduction to  File Handling with PHP
PHP - Introduction to File Handling with PHP
 
Statements and Conditions in PHP
Statements and Conditions in PHPStatements and Conditions in PHP
Statements and Conditions in PHP
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
 
JAVA AWT
JAVA AWTJAVA AWT
JAVA AWT
 
HTML Forms
HTML FormsHTML Forms
HTML Forms
 
Asp.NET Validation controls
Asp.NET Validation controlsAsp.NET Validation controls
Asp.NET Validation controls
 
Php introduction
Php introductionPhp introduction
Php introduction
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
 
Methods in Java
Methods in JavaMethods in Java
Methods in Java
 
Javascript arrays
Javascript arraysJavascript arrays
Javascript arrays
 
Php with MYSQL Database
Php with MYSQL DatabasePhp with MYSQL Database
Php with MYSQL Database
 
PHP variables
PHP  variablesPHP  variables
PHP variables
 
Wrapper class
Wrapper classWrapper class
Wrapper class
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Java constructors
Java constructorsJava constructors
Java constructors
 

Andere mochten auch (13)

Object Oriented Programming in PHP
Object Oriented Programming in PHPObject Oriented Programming in PHP
Object Oriented Programming in PHP
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
 
PHP Classes and OOPS Concept
PHP Classes and OOPS ConceptPHP Classes and OOPS Concept
PHP Classes and OOPS Concept
 
OOP in PHP
OOP in PHPOOP in PHP
OOP 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
 
Java Servlets & JSP
Java Servlets & JSPJava Servlets & JSP
Java Servlets & JSP
 
C vs c++
C vs c++C vs c++
C vs c++
 
APACHE TOMCAT
APACHE TOMCATAPACHE TOMCAT
APACHE TOMCAT
 
JSP
JSPJSP
JSP
 
Tomcat and apache httpd training
Tomcat and apache httpd trainingTomcat and apache httpd training
Tomcat and apache httpd training
 
Java Tutorial
Java TutorialJava Tutorial
Java Tutorial
 
Php Presentation
Php PresentationPhp Presentation
Php Presentation
 
Asp.net.
Asp.net.Asp.net.
Asp.net.
 

Ă„hnlich wie Introduction to OOP Concepts with PHP

Only oop
Only oopOnly oop
Only oopanitarooge
 
OOPS IN PHP.pptx
OOPS IN PHP.pptxOOPS IN PHP.pptx
OOPS IN PHP.pptxrani marri
 
ABAP Object oriented concepts
ABAP Object oriented conceptsABAP Object oriented concepts
ABAP Object oriented conceptsDharmeshKumar49
 
Introduction to objective c
Introduction to objective cIntroduction to objective c
Introduction to objective cSunny Shaikh
 
Object Oriented Programming C#
Object Oriented Programming C#Object Oriented Programming C#
Object Oriented Programming C#Muhammad Younis
 
Synapseindia object oriented programming in php
Synapseindia object oriented programming in phpSynapseindia object oriented programming in php
Synapseindia object oriented programming in phpSynapseindiappsdevelopment
 
System_Verilog_OOPS_Concepts.pdf
System_Verilog_OOPS_Concepts.pdfSystem_Verilog_OOPS_Concepts.pdf
System_Verilog_OOPS_Concepts.pdfPoothan
 
UNIT - IIInew.pptx
UNIT - IIInew.pptxUNIT - IIInew.pptx
UNIT - IIInew.pptxakila m
 
Object-oriented Analysis, Design & Programming
Object-oriented Analysis, Design & ProgrammingObject-oriented Analysis, Design & Programming
Object-oriented Analysis, Design & ProgrammingAllan Mangune
 
Learn C# Programming - Classes & Inheritance
Learn C# Programming - Classes & InheritanceLearn C# Programming - Classes & Inheritance
Learn C# Programming - Classes & InheritanceEng Teong Cheah
 
Class 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented ProgrammingClass 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented ProgrammingAhmed Swilam
 
Lecture-10_PHP-OOP.pptx
Lecture-10_PHP-OOP.pptxLecture-10_PHP-OOP.pptx
Lecture-10_PHP-OOP.pptxShaownRoy1
 
Presentation 3rd
Presentation 3rdPresentation 3rd
Presentation 3rdConnex
 
Object oriented approach in python programming
Object oriented approach in python programmingObject oriented approach in python programming
Object oriented approach in python programmingSrinivas Narasegouda
 
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
 
Object-oriented programming
Object-oriented programmingObject-oriented programming
Object-oriented programmingNeelesh Shukla
 

Ă„hnlich wie Introduction to OOP Concepts with PHP (20)

Only oop
Only oopOnly oop
Only oop
 
C# classes objects
C#  classes objectsC#  classes objects
C# classes objects
 
OOPS IN PHP.pptx
OOPS IN PHP.pptxOOPS IN PHP.pptx
OOPS IN PHP.pptx
 
ABAP Object oriented concepts
ABAP Object oriented conceptsABAP Object oriented concepts
ABAP Object oriented concepts
 
Introduction to objective c
Introduction to objective cIntroduction to objective c
Introduction to objective c
 
Object Oriented Programming C#
Object Oriented Programming C#Object Oriented Programming C#
Object Oriented Programming C#
 
Synapseindia object oriented programming in php
Synapseindia object oriented programming in phpSynapseindia object oriented programming in php
Synapseindia object oriented programming in php
 
System_Verilog_OOPS_Concepts.pdf
System_Verilog_OOPS_Concepts.pdfSystem_Verilog_OOPS_Concepts.pdf
System_Verilog_OOPS_Concepts.pdf
 
Php oop (1)
Php oop (1)Php oop (1)
Php oop (1)
 
UNIT - IIInew.pptx
UNIT - IIInew.pptxUNIT - IIInew.pptx
UNIT - IIInew.pptx
 
Object-oriented Analysis, Design & Programming
Object-oriented Analysis, Design & ProgrammingObject-oriented Analysis, Design & Programming
Object-oriented Analysis, Design & Programming
 
Learn C# Programming - Classes & Inheritance
Learn C# Programming - Classes & InheritanceLearn C# Programming - Classes & Inheritance
Learn C# Programming - Classes & Inheritance
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
Class 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented ProgrammingClass 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented Programming
 
Lecture-10_PHP-OOP.pptx
Lecture-10_PHP-OOP.pptxLecture-10_PHP-OOP.pptx
Lecture-10_PHP-OOP.pptx
 
Presentation 3rd
Presentation 3rdPresentation 3rd
Presentation 3rd
 
Object oriented approach in python programming
Object oriented approach in python programmingObject oriented approach in python programming
Object oriented approach in python programming
 
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
 
Object-oriented programming
Object-oriented programmingObject-oriented programming
Object-oriented programming
 
oopusingc.pptx
oopusingc.pptxoopusingc.pptx
oopusingc.pptx
 

Mehr von Vibrant Technologies & Computers

SQL Introduction to displaying data from multiple tables
SQL Introduction to displaying data from multiple tables  SQL Introduction to displaying data from multiple tables
SQL Introduction to displaying data from multiple tables Vibrant Technologies & Computers
 
Data ware housing - Introduction to data ware housing process.
Data ware housing - Introduction to data ware housing process.Data ware housing - Introduction to data ware housing process.
Data ware housing - Introduction to data ware housing process.Vibrant Technologies & Computers
 
Data ware housing- Introduction to data ware housing
Data ware housing- Introduction to data ware housingData ware housing- Introduction to data ware housing
Data ware housing- Introduction to data ware housingVibrant Technologies & Computers
 
Sas - Introduction to working under change management
Sas - Introduction to working under change managementSas - Introduction to working under change management
Sas - Introduction to working under change managementVibrant Technologies & Computers
 

Mehr von Vibrant Technologies & Computers (20)

Buisness analyst business analysis overview ppt 5
Buisness analyst business analysis overview ppt 5Buisness analyst business analysis overview ppt 5
Buisness analyst business analysis overview ppt 5
 
SQL Introduction to displaying data from multiple tables
SQL Introduction to displaying data from multiple tables  SQL Introduction to displaying data from multiple tables
SQL Introduction to displaying data from multiple tables
 
SQL- Introduction to MySQL
SQL- Introduction to MySQLSQL- Introduction to MySQL
SQL- Introduction to MySQL
 
SQL- Introduction to SQL database
SQL- Introduction to SQL database SQL- Introduction to SQL database
SQL- Introduction to SQL database
 
ITIL - introduction to ITIL
ITIL - introduction to ITILITIL - introduction to ITIL
ITIL - introduction to ITIL
 
Salesforce - Introduction to Security & Access
Salesforce -  Introduction to Security & Access Salesforce -  Introduction to Security & Access
Salesforce - Introduction to Security & Access
 
Data ware housing- Introduction to olap .
Data ware housing- Introduction to  olap .Data ware housing- Introduction to  olap .
Data ware housing- Introduction to olap .
 
Data ware housing - Introduction to data ware housing process.
Data ware housing - Introduction to data ware housing process.Data ware housing - Introduction to data ware housing process.
Data ware housing - Introduction to data ware housing process.
 
Data ware housing- Introduction to data ware housing
Data ware housing- Introduction to data ware housingData ware housing- Introduction to data ware housing
Data ware housing- Introduction to data ware housing
 
Salesforce - classification of cloud computing
Salesforce - classification of cloud computingSalesforce - classification of cloud computing
Salesforce - classification of cloud computing
 
Salesforce - cloud computing fundamental
Salesforce - cloud computing fundamentalSalesforce - cloud computing fundamental
Salesforce - cloud computing fundamental
 
SQL- Introduction to PL/SQL
SQL- Introduction to  PL/SQLSQL- Introduction to  PL/SQL
SQL- Introduction to PL/SQL
 
SQL- Introduction to advanced sql concepts
SQL- Introduction to  advanced sql conceptsSQL- Introduction to  advanced sql concepts
SQL- Introduction to advanced sql concepts
 
SQL Inteoduction to SQL manipulating of data
SQL Inteoduction to SQL manipulating of data   SQL Inteoduction to SQL manipulating of data
SQL Inteoduction to SQL manipulating of data
 
SQL- Introduction to SQL Set Operations
SQL- Introduction to SQL Set OperationsSQL- Introduction to SQL Set Operations
SQL- Introduction to SQL Set Operations
 
Sas - Introduction to designing the data mart
Sas - Introduction to designing the data martSas - Introduction to designing the data mart
Sas - Introduction to designing the data mart
 
Sas - Introduction to working under change management
Sas - Introduction to working under change managementSas - Introduction to working under change management
Sas - Introduction to working under change management
 
SAS - overview of SAS
SAS - overview of SASSAS - overview of SAS
SAS - overview of SAS
 
Teradata - Architecture of Teradata
Teradata - Architecture of TeradataTeradata - Architecture of Teradata
Teradata - Architecture of Teradata
 
Teradata - Restoring Data
Teradata - Restoring Data Teradata - Restoring Data
Teradata - Restoring Data
 

KĂĽrzlich hochgeladen

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
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
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 

KĂĽrzlich hochgeladen (20)

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 

Introduction to OOP Concepts with PHP

  • 1.
  • 2. Introduction to Object Oriented Programming with PHP
  • 3. Object Oriented ConceptObject Oriented Concept  Classes, which are the "blueprints" for an object and are the actual code that defines the properties and methods.  Objects, which are running instances of a class and contain all the internal data and state information needed for your application to function.  Encapsulation, which is the capability of an object to protect access to its internal data  Inheritance, which is the ability to define a class of one kind as being a sub-type of a different kind of class (much the same way a square is a kind of rectangle).
  • 4. Creating ClassCreating Class • Let's start with a simple example. Save the following in a file called class.lat.php: <?php class Demo { } ?>
  • 5. Adding MethodAdding Method • The Demo class isn't particularly useful if it isn't able to do anything, so let's look at how you can create a method. <?php class Demo { function SayHello($name) { echo “Hello $name !”; } } ?>
  • 6. Adding PropertiesAdding Properties • Adding a property to your class is as easy as adding a method. <?php class Demo { public $name; function SayHello() { echo “Hello $this->$name !”; } } ?>
  • 7. Object InstantiationObject Instantiation • You can instantiate an object of type Demo like this: <?php require_once('class.lat.php'); $objDemo = new Demo(); $objDemo->name = “Bayu”; $objDemo->SayHallo(); ?>
  • 8. Protecting Access toProtecting Access to Member VariablesMember Variables (1)(1) There are three different levels of visibility that a member variable or method can have :  Public â–Ş members are accessible to any and all code  Private â–Ş members are only accessible to the class itself  Protected â–Ş members are available to the class itself, and to classes that inherit from it Public is the default visibility level for any member variables or functions that do not explicitly set one, but it is good practice to always explicitly state the visibility of all the members of the class. Public is the default visibility level for any member variables or functions that do not explicitly set one, but it is good practice to always explicitly state the visibility of all the members of the class.
  • 9. Protecting Access toProtecting Access to Member VariablesMember Variables (2)(2) • Try to change access level of property named “name” to private of previous code. • What the possible solution of this problem? • Make the getter and setter function... Always use get and set functions for your properties. Changes to business logic and data validation requirements in the future will be much easier to implement. Always use get and set functions for your properties. Changes to business logic and data validation requirements in the future will be much easier to implement.
  • 10. Class ConstantsClass Constants  It is possible to define constant values on a per- class basis remaining the same and unchangeable.  Constants differ from normal variables in that you don't use the $ symbol to declare or use them  The value must be a constant expression, not (for example) a variable, a property, a result of a mathematical operation, or a function call
  • 11. Class Constants (cont.)Class Constants (cont.) <?php class MyClass {     const constant = 'constant value';     function showConstant() {         echo  self::constant . "n";     } } echo MyClass::constant . "n"; ?> <?php class MyClass {     const constant = 'constant value';     function showConstant() {         echo  self::constant . "n";     } } echo MyClass::constant . "n"; ?>
  • 12. Static KeywordStatic Keyword • Declaring class properties or methods as static makes them accessible without needing an instantiation of the class. • A property declared as static can not be accessed with an instantiated class object
  • 13.
  • 14. ContructorContructor • Constructor is the method that will be implemented when object has been initiated • Commonly, constructor is used to initialize the object • Use function __construct to create constructor in PHP <?php class Demo { function __construct { } } ?>
  • 15. DestructorDestructor • Destructor, is method that will be run when object is ended <?php class Demo { function __destruct { } } ?>
  • 16. InheritanceInheritance • There are many benefits of inheritance with PHP, the most common is simplifying and reducing instances of redundant code.
  • 17. Inheritance (2)Inheritance (2) class hewan { protected $jml_kaki; protected $warna_kulit; function __construct() { } function berpindah() { echo "Saya berpindah"; } function makan() { echo "Saya makan"; } } class hewan { protected $jml_kaki; protected $warna_kulit; function __construct() { } function berpindah() { echo "Saya berpindah"; } function makan() { echo "Saya makan"; } }
  • 20. Tugas (cont.)Tugas (cont.)  Class product :  name  price  discount  Class CDMusic :  artist  Genre  Class CDRack  capacity  model
  • 21. Tugas (cont.)Tugas (cont.)  CDMusic  Menuruni name, price dan discount dari Product  Price = price + 10%  Ada penambahan 5% pada discount  CDRack  Menuruni name, price dan discount dari Product  Price = price + 15%  Tidak ada penambahan discount  Buatlah code dalam PHP, serta simulasi untuk kasus tersebut!
  • 22. ThankThank You !!!You !!! For More Information click below link: Follow Us on: http://vibranttechnologies.co.in/php-classes-in- mumbai.html