SlideShare a Scribd company logo
PHP Basic Part 2




    www.prodigyview.com
Overview
Objective

For beginners to further their knowledge of PHP by
providing a greater understanding of objects and
functions.

Requirements

 Understanding of variables, methods and classes
Estimated Time

8 minutes


                     www.prodigyview.com
Follow Along With A Code
          Example
1. Download a copy of the example code at
  www.prodigyview.com/source.

2. Install the system in an environment you feel
  comfortable testing in.

3. Proceed to examples/basics/PHP_Basics.php




                   http://www.prodigyview.com
Concepts Covered
 Static Methods
 Public Methods
 Protected Methods
 Private Methods
 Anonymous Functions




                      www.prodigyview.com
Static Methods
So you’ve come to the point after PHP Basics Part 1, that you are
ready to dive a little deeper. Who am I to hold you back?

If you remember from part 1, we worked with objects with methods.
Now we are going to work with objects that have static methods.

What is a static method?

A static method is a method that can be called without instantiating
the object. Simply put, we can access the method without using
‘new Object()’. Static methods are accessed by using this syntax:
‘class_name ::method_name’ .



                           www.prodigyview.com
Static Method Example
1. Define a method as Static
                Creating A Static Method




              Executing A Static Method


  2. Use the ‘::’ to call/execute the method
Public Methods
In our last slide we created a method and also declared it
as public. A method that is ‘public’ means that any other
user outside the object can call the function. Here is the
code again on declaring a static method.




                          Sets the method as public
Protected Methods
Next up, protected methods. These methods differ from
public methods in that only another method inside the
current object can call this method. Protected methods
can also be called by children classes when they are
extended. We will get into extending a class into a minute.




                   Sets the method as protected
Private Methods
And finally we get to private methods. Private methods
are like protected methods in that only another method
inside the class can call it. But they differ from protected
methods in that they cannot to be extended.




                   Sets the method as private
Our Class




www.prodigyview.com
Extending A Class
So far it’s been mentioned twice about extending a class.

What does this mean?

Extending a class mean that you can create another class
and give all the public and protected properties of one
class to another class. Private methods CANNOT be
given to another class.

So we have the class ParentObject. Let us give(extend)
it’s methods to another class.



                     www.prodigyview.com
Extending ParentObject




          Calls the protected function of ParentObject

       www.prodigyview.com
Anonymous Functions
Finally for this tutorial we have anonymous functions,
which are also known as closures.

These are functions that be created on the fly and do not
have to be actually declared until needed. Anonymous
functions can also be stored in a variable, which can be
stored in an array and passed to functions and methods.
Let’s create a simple closure.




                     www.prodigyview.com
Creating and Storing Closure
1. Assign the function to a variable




                                2. Calls the function through the variable
                               www.prodigyview.com
Challenge!
To better understand the concepts presented, an optional
challenge is being presented.

Your challenge for this tutorial is to create a class that has
a static protected method. That static method will have an
anonymous function that adds two variables and returns
the value of the variables added.

Extended that class to another and through a public
method, call the protected one.




                       www.prodigyview.com
Review
1. Static methods are accessed with ‘::’ operator.
2. Objects do not have to be instantiated to use a static
   method.
3. Public methods are accessible by everyone.
4. Protected methods are also accessible to other methods
   within the object and children classes.
5. Private methods are only accessible to methods within the
   current class.
6. Closures/Anonymous Functions can be assigned to a
   variable.



                       www.prodigyview.com
More Tutorials
For more tutorials, please visit:

http://www.prodigyview.com/tutorials




                     www.prodigyview.com

More Related Content

Similar to Learning PHP Basics Part 2

Creating Dynamic Objects PHP
Creating Dynamic Objects PHPCreating Dynamic Objects PHP
Creating Dynamic Objects PHP
ProdigyView
 
OOP presentation.pptx
OOP presentation.pptxOOP presentation.pptx
OOP presentation.pptx
AbulHasnatHridoy2211
 
Object oreinted php | OOPs
Object oreinted php | OOPsObject oreinted php | OOPs
Object oreinted php | OOPs
Ravi Bhadauria
 
OOP_presentation.pptx
OOP_presentation.pptxOOP_presentation.pptx
OOP_presentation.pptx
AbulHasnatHridoy2211
 
Java sessionnotes
Java sessionnotesJava sessionnotes
Java sessionnotes
Lakshmi Sarvani Videla
 
Lecture 17
Lecture 17Lecture 17
Lecture 17
talha ijaz
 
(An Extended) Beginners Guide to Object Orientation in PHP
(An Extended) Beginners Guide to Object Orientation in PHP(An Extended) Beginners Guide to Object Orientation in PHP
(An Extended) Beginners Guide to Object Orientation in PHP
Rick Ogden
 
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
 
Chapter 8 java
Chapter 8 javaChapter 8 java
Chapter 8 java
Ahmad sohail Kakar
 
Java Inheritance
Java InheritanceJava Inheritance
Java Inheritance
Rosie Jane Enomar
 
Lesson 13 object and class
Lesson 13 object and classLesson 13 object and class
Lesson 13 object and class
MLG College of Learning, Inc
 
OOP in Java Presentation.pptx
OOP in Java Presentation.pptxOOP in Java Presentation.pptx
OOP in Java Presentation.pptx
mrxyz19
 
Python_Unit_3.pdf
Python_Unit_3.pdfPython_Unit_3.pdf
Python_Unit_3.pdf
alaparthi
 
The Ring programming language version 1.5.1 book - Part 68 of 180
The Ring programming language version 1.5.1 book - Part 68 of 180The Ring programming language version 1.5.1 book - Part 68 of 180
The Ring programming language version 1.5.1 book - Part 68 of 180
Mahmoud Samir Fayed
 
Synapseindia strcture of dotnet development part 1
Synapseindia strcture of dotnet development part 1Synapseindia strcture of dotnet development part 1
Synapseindia strcture of dotnet development part 1
Synapseindiappsdevelopment
 
This and Static Keyword
This and Static KeywordThis and Static Keyword
This and Static Keyword
Dhrumil Panchal
 
chapter 5 concepts of object oriented programming
chapter 5 concepts of object oriented programmingchapter 5 concepts of object oriented programming
chapter 5 concepts of object oriented programming
WondimuBantihun1
 
Java unit 7
Java unit 7Java unit 7
Java unit 7
Shipra Swati
 
Object_oriented_programming_OOP_with_PHP.pdf
Object_oriented_programming_OOP_with_PHP.pdfObject_oriented_programming_OOP_with_PHP.pdf
Object_oriented_programming_OOP_with_PHP.pdf
GammingWorld2
 
UNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
UNIT-2.pptx CS3391 Inheritance , types, packages and InterfacesUNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
UNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
SakkaravarthiS1
 

Similar to Learning PHP Basics Part 2 (20)

Creating Dynamic Objects PHP
Creating Dynamic Objects PHPCreating Dynamic Objects PHP
Creating Dynamic Objects PHP
 
OOP presentation.pptx
OOP presentation.pptxOOP presentation.pptx
OOP presentation.pptx
 
Object oreinted php | OOPs
Object oreinted php | OOPsObject oreinted php | OOPs
Object oreinted php | OOPs
 
OOP_presentation.pptx
OOP_presentation.pptxOOP_presentation.pptx
OOP_presentation.pptx
 
Java sessionnotes
Java sessionnotesJava sessionnotes
Java sessionnotes
 
Lecture 17
Lecture 17Lecture 17
Lecture 17
 
(An Extended) Beginners Guide to Object Orientation in PHP
(An Extended) Beginners Guide to Object Orientation in PHP(An Extended) Beginners Guide to Object Orientation in PHP
(An Extended) Beginners Guide to Object Orientation in PHP
 
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
 
Chapter 8 java
Chapter 8 javaChapter 8 java
Chapter 8 java
 
Java Inheritance
Java InheritanceJava Inheritance
Java Inheritance
 
Lesson 13 object and class
Lesson 13 object and classLesson 13 object and class
Lesson 13 object and class
 
OOP in Java Presentation.pptx
OOP in Java Presentation.pptxOOP in Java Presentation.pptx
OOP in Java Presentation.pptx
 
Python_Unit_3.pdf
Python_Unit_3.pdfPython_Unit_3.pdf
Python_Unit_3.pdf
 
The Ring programming language version 1.5.1 book - Part 68 of 180
The Ring programming language version 1.5.1 book - Part 68 of 180The Ring programming language version 1.5.1 book - Part 68 of 180
The Ring programming language version 1.5.1 book - Part 68 of 180
 
Synapseindia strcture of dotnet development part 1
Synapseindia strcture of dotnet development part 1Synapseindia strcture of dotnet development part 1
Synapseindia strcture of dotnet development part 1
 
This and Static Keyword
This and Static KeywordThis and Static Keyword
This and Static Keyword
 
chapter 5 concepts of object oriented programming
chapter 5 concepts of object oriented programmingchapter 5 concepts of object oriented programming
chapter 5 concepts of object oriented programming
 
Java unit 7
Java unit 7Java unit 7
Java unit 7
 
Object_oriented_programming_OOP_with_PHP.pdf
Object_oriented_programming_OOP_with_PHP.pdfObject_oriented_programming_OOP_with_PHP.pdf
Object_oriented_programming_OOP_with_PHP.pdf
 
UNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
UNIT-2.pptx CS3391 Inheritance , types, packages and InterfacesUNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
UNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
 

More from ProdigyView

Installing Plug-ins
Installing Plug-insInstalling Plug-ins
Installing Plug-ins
ProdigyView
 
Building An Application
Building An ApplicationBuilding An Application
Building An Application
ProdigyView
 
Installing Applications
Installing ApplicationsInstalling Applications
Installing Applications
ProdigyView
 
Video Content Management
Video Content ManagementVideo Content Management
Video Content Management
ProdigyView
 
Audio Content Management
Audio Content ManagementAudio Content Management
Audio Content Management
ProdigyView
 
File Content Management
File Content ManagementFile Content Management
File Content Management
ProdigyView
 
Email Configuration
Email ConfigurationEmail Configuration
Email Configuration
ProdigyView
 
HTML5 Tags and Elements Tutorial
HTML5 Tags and Elements TutorialHTML5 Tags and Elements Tutorial
HTML5 Tags and Elements Tutorial
ProdigyView
 
HTML Forms Tutorial
HTML Forms TutorialHTML Forms Tutorial
HTML Forms Tutorial
ProdigyView
 
Html Tags Tutorial
Html Tags TutorialHtml Tags Tutorial
Html Tags Tutorial
ProdigyView
 
Video Conversion PHP
Video Conversion PHPVideo Conversion PHP
Video Conversion PHP
ProdigyView
 
Sending Email Basics PHP
Sending Email Basics PHPSending Email Basics PHP
Sending Email Basics PHP
ProdigyView
 
Tools ProdigyView
Tools ProdigyViewTools ProdigyView
Tools ProdigyView
ProdigyView
 
Custom Validation PHP
Custom Validation PHPCustom Validation PHP
Custom Validation PHP
ProdigyView
 
Basic File Cache Tutorial - PHP
Basic File Cache Tutorial - PHPBasic File Cache Tutorial - PHP
Basic File Cache Tutorial - PHP
ProdigyView
 
Understanding Web Cache
Understanding Web CacheUnderstanding Web Cache
Understanding Web Cache
ProdigyView
 
Javascript And CSS Libraries
Javascript And CSS LibrariesJavascript And CSS Libraries
Javascript And CSS Libraries
ProdigyView
 
SQL Prepared Statements Tutorial
SQL Prepared Statements TutorialSQL Prepared Statements Tutorial
SQL Prepared Statements Tutorial
ProdigyView
 
Database Basics
Database BasicsDatabase Basics
Database Basics
ProdigyView
 
Implementing the Adapter Design Pattern
Implementing the Adapter Design PatternImplementing the Adapter Design Pattern
Implementing the Adapter Design Pattern
ProdigyView
 

More from ProdigyView (20)

Installing Plug-ins
Installing Plug-insInstalling Plug-ins
Installing Plug-ins
 
Building An Application
Building An ApplicationBuilding An Application
Building An Application
 
Installing Applications
Installing ApplicationsInstalling Applications
Installing Applications
 
Video Content Management
Video Content ManagementVideo Content Management
Video Content Management
 
Audio Content Management
Audio Content ManagementAudio Content Management
Audio Content Management
 
File Content Management
File Content ManagementFile Content Management
File Content Management
 
Email Configuration
Email ConfigurationEmail Configuration
Email Configuration
 
HTML5 Tags and Elements Tutorial
HTML5 Tags and Elements TutorialHTML5 Tags and Elements Tutorial
HTML5 Tags and Elements Tutorial
 
HTML Forms Tutorial
HTML Forms TutorialHTML Forms Tutorial
HTML Forms Tutorial
 
Html Tags Tutorial
Html Tags TutorialHtml Tags Tutorial
Html Tags Tutorial
 
Video Conversion PHP
Video Conversion PHPVideo Conversion PHP
Video Conversion PHP
 
Sending Email Basics PHP
Sending Email Basics PHPSending Email Basics PHP
Sending Email Basics PHP
 
Tools ProdigyView
Tools ProdigyViewTools ProdigyView
Tools ProdigyView
 
Custom Validation PHP
Custom Validation PHPCustom Validation PHP
Custom Validation PHP
 
Basic File Cache Tutorial - PHP
Basic File Cache Tutorial - PHPBasic File Cache Tutorial - PHP
Basic File Cache Tutorial - PHP
 
Understanding Web Cache
Understanding Web CacheUnderstanding Web Cache
Understanding Web Cache
 
Javascript And CSS Libraries
Javascript And CSS LibrariesJavascript And CSS Libraries
Javascript And CSS Libraries
 
SQL Prepared Statements Tutorial
SQL Prepared Statements TutorialSQL Prepared Statements Tutorial
SQL Prepared Statements Tutorial
 
Database Basics
Database BasicsDatabase Basics
Database Basics
 
Implementing the Adapter Design Pattern
Implementing the Adapter Design PatternImplementing the Adapter Design Pattern
Implementing the Adapter Design Pattern
 

Recently uploaded

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
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
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
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
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
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
Jen Stirrup
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 

Recently uploaded (20)

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
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
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
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
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
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 

Learning PHP Basics Part 2

  • 1. PHP Basic Part 2 www.prodigyview.com
  • 2. Overview Objective For beginners to further their knowledge of PHP by providing a greater understanding of objects and functions. Requirements  Understanding of variables, methods and classes Estimated Time 8 minutes www.prodigyview.com
  • 3. Follow Along With A Code Example 1. Download a copy of the example code at www.prodigyview.com/source. 2. Install the system in an environment you feel comfortable testing in. 3. Proceed to examples/basics/PHP_Basics.php http://www.prodigyview.com
  • 4. Concepts Covered  Static Methods  Public Methods  Protected Methods  Private Methods  Anonymous Functions www.prodigyview.com
  • 5. Static Methods So you’ve come to the point after PHP Basics Part 1, that you are ready to dive a little deeper. Who am I to hold you back? If you remember from part 1, we worked with objects with methods. Now we are going to work with objects that have static methods. What is a static method? A static method is a method that can be called without instantiating the object. Simply put, we can access the method without using ‘new Object()’. Static methods are accessed by using this syntax: ‘class_name ::method_name’ . www.prodigyview.com
  • 6. Static Method Example 1. Define a method as Static Creating A Static Method Executing A Static Method 2. Use the ‘::’ to call/execute the method
  • 7. Public Methods In our last slide we created a method and also declared it as public. A method that is ‘public’ means that any other user outside the object can call the function. Here is the code again on declaring a static method. Sets the method as public
  • 8. Protected Methods Next up, protected methods. These methods differ from public methods in that only another method inside the current object can call this method. Protected methods can also be called by children classes when they are extended. We will get into extending a class into a minute. Sets the method as protected
  • 9. Private Methods And finally we get to private methods. Private methods are like protected methods in that only another method inside the class can call it. But they differ from protected methods in that they cannot to be extended. Sets the method as private
  • 11. Extending A Class So far it’s been mentioned twice about extending a class. What does this mean? Extending a class mean that you can create another class and give all the public and protected properties of one class to another class. Private methods CANNOT be given to another class. So we have the class ParentObject. Let us give(extend) it’s methods to another class. www.prodigyview.com
  • 12. Extending ParentObject Calls the protected function of ParentObject www.prodigyview.com
  • 13. Anonymous Functions Finally for this tutorial we have anonymous functions, which are also known as closures. These are functions that be created on the fly and do not have to be actually declared until needed. Anonymous functions can also be stored in a variable, which can be stored in an array and passed to functions and methods. Let’s create a simple closure. www.prodigyview.com
  • 14. Creating and Storing Closure 1. Assign the function to a variable 2. Calls the function through the variable www.prodigyview.com
  • 15. Challenge! To better understand the concepts presented, an optional challenge is being presented. Your challenge for this tutorial is to create a class that has a static protected method. That static method will have an anonymous function that adds two variables and returns the value of the variables added. Extended that class to another and through a public method, call the protected one. www.prodigyview.com
  • 16. Review 1. Static methods are accessed with ‘::’ operator. 2. Objects do not have to be instantiated to use a static method. 3. Public methods are accessible by everyone. 4. Protected methods are also accessible to other methods within the object and children classes. 5. Private methods are only accessible to methods within the current class. 6. Closures/Anonymous Functions can be assigned to a variable. www.prodigyview.com
  • 17. More Tutorials For more tutorials, please visit: http://www.prodigyview.com/tutorials www.prodigyview.com