SlideShare una empresa de Scribd logo
1 de 9
New Object-Oriented Features
☞ public/private/protected access
modifiers for methods and properties.
Allows the use of common OO access
modifiers to control access to
methods and properties:
class MyClass {
private $id = 18;
public function getId() {
return $this->id;
}
}
☞ Unified constructor name
__construct().
Instead of the constructor being the
name of the class, it is now declared
as __construct(), which makes it
easier to shift classes inside class
hierarchies:
class MyClass {
function __construct() {
print "Inside constructor";
}
}
☞ Object destructor support by
defining a __destructor() method.
Allows defining a destructor function
that runs when an object
is destroyed:
class MyClass {
function __destruct() {
print ”Destroying object”;
}
}
☞ Interfaces.
Gives the ability for a class to fulfill more
than one is-a relationships. A class can
inherit only from one class, but may
implement as many interfaces as it wants:
interface Display {
function display();
}
class Circle implements Display {
function display() {
print "Displaying circlen";
}
}
☞ instanceof operator.
Language-level support for is-a
relationship checking. The PHP 4
is_a() function
is now deprecated:
if ($obj instanceof Circle) {
print '$obj is a Circle';
}
☞ Final methods.
The final keyword allows you to mark
methods so that an inheriting class
cannot overload
them:
class MyClass {
final function getBaseClassName() {
return __CLASS__;
}
}
☞ Final classes.
After declaring a class as final, it
cannot be inherited. The following
example
would error out.
final class FinalClass {
}
class BogusClass extends FinalClass {
}
☞ Static methods.
You can now define methods as static by
allowing them to be called from
non-object context. Static methods do not
define the $this variable
because they are not bound to any specific
object:
class MyClass {
static function helloWorld() {
print "Hello, world";
}
}
MyClass::helloWorld();
• ☞ Abstract classes.
• A class may be declared abstract to prevent it
from being instantiated.
• However, you may inherit from an abstract class:
• abstract class MyBaseClass {
• function display() {
• print "Default display routine being called";
• }
• }

Más contenido relacionado

La actualidad más candente

Intro to HTML5 Web Storage
Intro to HTML5 Web StorageIntro to HTML5 Web Storage
Intro to HTML5 Web Storage
dylanks
 
SXML: S-expression eXtensible Markup Language
SXML: S-expression eXtensible Markup LanguageSXML: S-expression eXtensible Markup Language
SXML: S-expression eXtensible Markup Language
elliando dias
 

La actualidad más candente (16)

Jiemamy inside 2
Jiemamy inside 2Jiemamy inside 2
Jiemamy inside 2
 
D3 meetup (Backbone and D3)
D3 meetup (Backbone and D3)D3 meetup (Backbone and D3)
D3 meetup (Backbone and D3)
 
Intro to HTML5 Web Storage
Intro to HTML5 Web StorageIntro to HTML5 Web Storage
Intro to HTML5 Web Storage
 
Php update and delet operation
Php update and delet operationPhp update and delet operation
Php update and delet operation
 
React.js 20150828
React.js 20150828React.js 20150828
React.js 20150828
 
ActiveRecord
ActiveRecordActiveRecord
ActiveRecord
 
Mysocial databasequeries
Mysocial databasequeriesMysocial databasequeries
Mysocial databasequeries
 
Mysocial databasequeries
Mysocial databasequeriesMysocial databasequeries
Mysocial databasequeries
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Understand Properties in Codename One
Understand Properties in Codename One Understand Properties in Codename One
Understand Properties in Codename One
 
Enonic Content Repository built on elasticsearch
Enonic Content Repository built on elasticsearchEnonic Content Repository built on elasticsearch
Enonic Content Repository built on elasticsearch
 
Active Record
Active RecordActive Record
Active Record
 
SXML: S-expression eXtensible Markup Language
SXML: S-expression eXtensible Markup LanguageSXML: S-expression eXtensible Markup Language
SXML: S-expression eXtensible Markup Language
 
Agile Data concept introduction
Agile Data   concept introductionAgile Data   concept introduction
Agile Data concept introduction
 
Lock basicsexamples
Lock basicsexamplesLock basicsexamples
Lock basicsexamples
 
Save data in to sqlite
Save data in to sqliteSave data in to sqlite
Save data in to sqlite
 

Similar a Php5

OOPS IN PHP.pptx
OOPS IN PHP.pptxOOPS IN PHP.pptx
OOPS IN PHP.pptx
rani marri
 
CSharp presentation and software developement
CSharp presentation and software developementCSharp presentation and software developement
CSharp presentation and software developement
frwebhelp
 

Similar a Php5 (20)

Lab 4 (1).pdf
Lab 4 (1).pdfLab 4 (1).pdf
Lab 4 (1).pdf
 
Jscript part2
Jscript part2Jscript part2
Jscript part2
 
Demystifying Object-Oriented Programming - PHP UK Conference 2017
Demystifying Object-Oriented Programming - PHP UK Conference 2017Demystifying Object-Oriented Programming - PHP UK Conference 2017
Demystifying Object-Oriented Programming - PHP UK Conference 2017
 
lecture3.pptx
lecture3.pptxlecture3.pptx
lecture3.pptx
 
OOPs & C++ UNIT 3
OOPs & C++ UNIT 3OOPs & C++ UNIT 3
OOPs & C++ UNIT 3
 
Only oop
Only oopOnly oop
Only oop
 
object oriented programming language by c++
object oriented programming language by c++object oriented programming language by c++
object oriented programming language by c++
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Opp concept in c++
Opp concept in c++Opp concept in c++
Opp concept in c++
 
Classes and Objects in C#
Classes and Objects in C#Classes and Objects in C#
Classes and Objects in C#
 
Class and object
Class and objectClass and object
Class and object
 
PHP OOP Lecture - 03.pptx
PHP OOP Lecture - 03.pptxPHP OOP Lecture - 03.pptx
PHP OOP Lecture - 03.pptx
 
Lecture 4.2 c++(comlete reference book)
Lecture 4.2 c++(comlete reference book)Lecture 4.2 c++(comlete reference book)
Lecture 4.2 c++(comlete reference book)
 
Object Oriented Programming - 5. Class & Object
Object Oriented Programming - 5. Class & ObjectObject Oriented Programming - 5. Class & Object
Object Oriented Programming - 5. Class & Object
 
Class and object in C++ By Pawan Thakur
Class and object in C++ By Pawan ThakurClass and object in C++ By Pawan Thakur
Class and object in C++ By Pawan Thakur
 
Lecture 2, c++(complete reference,herbet sheidt)chapter-12
Lecture 2, c++(complete reference,herbet sheidt)chapter-12Lecture 2, c++(complete reference,herbet sheidt)chapter-12
Lecture 2, c++(complete reference,herbet sheidt)chapter-12
 
class c++
class c++class c++
class c++
 
Object and class presentation
Object and class presentationObject and class presentation
Object and class presentation
 
OOPS IN PHP.pptx
OOPS IN PHP.pptxOOPS IN PHP.pptx
OOPS IN PHP.pptx
 
CSharp presentation and software developement
CSharp presentation and software developementCSharp presentation and software developement
CSharp presentation and software developement
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

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
 
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
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
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
 
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
 
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
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
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
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
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
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 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
 
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
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 

Php5

  • 1. New Object-Oriented Features ☞ public/private/protected access modifiers for methods and properties. Allows the use of common OO access modifiers to control access to methods and properties: class MyClass { private $id = 18; public function getId() { return $this->id; } }
  • 2. ☞ Unified constructor name __construct(). Instead of the constructor being the name of the class, it is now declared as __construct(), which makes it easier to shift classes inside class hierarchies: class MyClass { function __construct() { print "Inside constructor"; } }
  • 3. ☞ Object destructor support by defining a __destructor() method. Allows defining a destructor function that runs when an object is destroyed: class MyClass { function __destruct() { print ”Destroying object”; } }
  • 4. ☞ Interfaces. Gives the ability for a class to fulfill more than one is-a relationships. A class can inherit only from one class, but may implement as many interfaces as it wants: interface Display { function display(); } class Circle implements Display { function display() { print "Displaying circlen"; } }
  • 5. ☞ instanceof operator. Language-level support for is-a relationship checking. The PHP 4 is_a() function is now deprecated: if ($obj instanceof Circle) { print '$obj is a Circle'; }
  • 6. ☞ Final methods. The final keyword allows you to mark methods so that an inheriting class cannot overload them: class MyClass { final function getBaseClassName() { return __CLASS__; } }
  • 7. ☞ Final classes. After declaring a class as final, it cannot be inherited. The following example would error out. final class FinalClass { } class BogusClass extends FinalClass { }
  • 8. ☞ Static methods. You can now define methods as static by allowing them to be called from non-object context. Static methods do not define the $this variable because they are not bound to any specific object: class MyClass { static function helloWorld() { print "Hello, world"; } } MyClass::helloWorld();
  • 9. • ☞ Abstract classes. • A class may be declared abstract to prevent it from being instantiated. • However, you may inherit from an abstract class: • abstract class MyBaseClass { • function display() { • print "Default display routine being called"; • } • }