SlideShare a Scribd company logo
PHP
Object Oriented Concepts
PHP 4, PHP 5 & PHP 6
■ There are substantial differences between PHP 4 and PHP
5. Most of the hype was around the new object model,
which was completely rewritten in PHP5. The PHP 5 version
is much more complete, and performs much better as well.
In PHP 4, objects were really just primitive data types, and
were referenced by value. In an attempt to retain as much
backward compatibility as possible in PHP 5 allows
compatibility with the version 4 methods.
■ With the release of PHP 5 in 2004, PHP programmers
finally had the power to code like the Java and C#, PHP
finally had a complete OOP infrastructure.
■ PHP 6 has more features of object Oriented Concepts.
Step by Step Process
■ The difference between building a PHP application the old fashioned
(procedural) way versus the OOP way.
■ What the basic OOP principles are, and how to use them in PHP?
■ When to use OOP in your PHP scripts?
www.mindfiresolutions.comwww.mindfiresolutions.com |
www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires |
http://wikipedia.org/wiki/mindfire_solutions
Object Oriented PHP
How to develop a OO PHP ?? to get into this we are going to divide the
process into 22 steps by which we can get a basic idea to develop an
application in OOP Concepts.
STEP 1
First lets create 2 PHP files
index.php
class_lib.php
OOP is all about creating modular code, so our object oriented PHP
code will be contained in dedicated files that we will then insert into our
normal PHP page using PHP 'includes'.
In this case, all our OO PHP code will be in the PHP file: class_lib.php
In OOP codes revolves around a 'class', Classes are the templates that
are used to define objects.
STEP 2
Create a simple PHP class (in class_lib.php)
Instead of having a bunch of functions, variables and code floating
around, to design our PHP scripts in the OOP way, we need to create our
own classes.
keyword 'class'
www.mindfiresolutions.comwww.mindfiresolutions.com |
www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires |
http://wikipedia.org/wiki/mindfire_solutions
STEP 2 ( conti ...)
<?php
class classname
{
}
?>
STEP 3 (add data to your class)
Classes are the blueprints for php objects. One of the big differences
between functions and classes is that a class contains both data (variables)
and functions that form a package called an: 'object'.
When you create a variable inside a class, it is called a 'property'.
<?php
class classname
{
// var $name is called as properties of class var keyword
var $name;
}
?>
www.mindfiresolutions.comwww.mindfiresolutions.com |
www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires |
http://wikipedia.org/wiki/mindfire_solutions
STEP 4 (add functions/methods to your class)
Functions also referred by different name when created inside a class - they
are called 'methods'.
A class's methods are used to manipulate its own data / properties.
<?php
class mfs_employee
{
var $name;
function set_name($new_name)
{
$this->name =
$new_name;
}
function get_name()
{
return $this->name;
}
}
?>
www.mindfiresolutions.comwww.mindfiresolutions.com |
www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires |
http://wikipedia.org/wiki/mindfire_solutions
STEP 5 (getter and setter functions)
We've created two interesting functions/methods: get_name() and set_name().
These methods follow a common OOP convention that you see in many
languages (including Java and Ruby) - where you create methods to 'set' and
'get' properties in a class.
NOTE : Another convention (a naming convention,) is that getter and setter
names should match the property names.
This way, when other PHP programmers want to use your objects, they will
know that if you have a method/function called 'set_name()', there will be a
property/variable called 'name'.
<?php
class mfs_employee
{
var $name;
function
set_name($new_name)
{
$this->name =
$new_name;
}
function get_name()
{
return $this-
>name;
}
}
?>
www.mindfiresolutions.comwww.mindfiresolutions.com |
www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires |
http://wikipedia.org/wiki/mindfire_solutions
STEP 6 (The '$this' variable)
$this->name = $new_name;
$this is a built-in variable which points to the current object. Or in other
words, $this is a special self-referencing variable. We use $this to access
properties and to call other methods of the current class.
STEP 7 (Use our class in our main PHP page : index.php )
We should not create the PHP classes in our main page, else it will
break the main purpose of building applications in OOP.
So in index.php include the file ( class_lib.php )
<?php include('class_lib.php'); ?>
www.mindfiresolutions.comwww.mindfiresolutions.com |
www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires |
http://wikipedia.org/wiki/mindfire_solutions
STEP 8 ( Instantiate/create your object )
Classes are the blueprints/templates of php objects. Classes don't
actually become objects until you do something called: instantiation.
When you instantiate a class, you create an instance of it ... thus
creating the object.
In other words, instantiation is the process of creating an instance of
an object in memory. What memory? The server's memory of
course!
<?php
$obj_mfsemp = new mfs_employee();
?>
Note: The variable $obj_mfsemp becomes a handle/reference to
our newly created mfs_employee class. It is a 'handle', because we
will use $obj_mfsemp to control and use the mfs_employee class.
www.mindfiresolutions.comwww.mindfiresolutions.com |
www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires |
http://wikipedia.org/wiki/mindfire_solutions
STEP 9 ( new keyword )
To create an object out of a class, you need to use the 'new'
keyword.
When creating/instantiating a class, we can optionally add brackets
to the class name, as below example. To be clear, we can see in the
code below how we create multiple objects from the same class.
From the PHP's engine point of view, each object is its own entity.
<?php
$obj_mfsemp1 = new mfs_employee ();
$obj_mfsemp2 = new mfs_employee ;
?>
www.mindfiresolutions.comwww.mindfiresolutions.com |
www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires |
http://wikipedia.org/wiki/mindfire_solutions
STEP 10 ( Set an objects properties )
Now that we've created/instantiated our two separate
'mfs_employee' objects, we can set their properties using the
methods (the setters) we created.
Please keep in mind that though both our mfs_employee objects
($obj_mfsemp1 and $obj_mfsemp2) are based on the same
'mfs_employee' class, as far as php is concerned, they are totally
different objects.
<?php
$obj_mfsemp1 = new mfs_employee ();
$obj_mfsemp2 = new mfs_employee ;
$obj_mfsemp1->set_name("Abinash Grahacharya");
$obj_mfsemp2->set_name("Amitabh Pattnaik");
?>
www.mindfiresolutions.comwww.mindfiresolutions.com |
www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires |
http://wikipedia.org/wiki/mindfire_solutions
STEP 11 ( Accessing an object's data )
Now we use the getter methods to access the data held in our
objects … this is the same data we inserted into our objects
using the setter methods.
When accessing methods and properties of a class, we use the
arrow (->) operator.
<?php
$obj_mfsemp1 = new mfs_employee ();
$obj_mfsemp2 = new mfs_employee ;
//setting values in the object
$obj_mfsemp1->set_name("Abinash Grahacharya");
$obj_mfsemp2->set_name("Amitabh Pattnaik");
//getting each values from the object
echo $obj_mfsemp1 -> get_name();
echo "<br />";
echo $obj_mfsemp2 -> get_name();
?>
www.mindfiresolutions.comwww.mindfiresolutions.com |
www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires |
http://wikipedia.org/wiki/mindfire_solutions
In this short period of time, we have covered
Designed a PHP class.
Generate/created a couple of objects based on your class.
Inserted data into your objects.
Retrieved data from your objects.
Lets now focus on PHP OBJECT.
www.mindfiresolutions.comwww.mindfiresolutions.com |
www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires |
http://wikipedia.org/wiki/mindfire_solutions
STEP 12 ( Directly accessing properties - don't do it! )
We don't have to use methods to access objects properties; you can
directly get to them using the arrow operator (->) and the name of
the variable.
For example: with the property $name (in object $obj_mfsemp1,) we
can get its' value like :
<?php
echo $obj_mfsemp1->name;
?>
NOTE : Though doable, it is considered bad practice to do it
because it can lead to trouble down the road. We should use getter
methods instead.
www.mindfiresolutions.comwww.mindfiresolutions.com |
www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires |
http://wikipedia.org/wiki/mindfire_solutions
STEP 13 ( Constructor )
All objects can have a special built-in method called a 'constructor'. Constructors
allow you to initialize your object's properties (give values to properties) when we
instantiate (create) an object.
Note: If you create a __construct() function PHP will automatically call the
__construct() method/function when you create an object from your class.
The 'construct' method starts with two underscores (__) and the word 'construct'.
<?php
class mfs_employee
{
var $name;
function
__construct($con_name)
{
$this->name =
$con_name;
}
function set_name($new_name)
{
$this->name =
$new_name;
}
function get_name()
{
return $this-
>name;
}
}
?>
www.mindfiresolutions.comwww.mindfiresolutions.com |
www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires |
http://wikipedia.org/wiki/mindfire_solutions
STEP 14 ( Create an object with a constructor )
Now that we've created a constructor method, we can provide a
value for the $name property when we create our objects for the
class mfs_employee.
We 'feed' the constructor method by providing a list of arguments
(like we do with a function) after the class name at the time of object
declaration.
Not a constructor
<?php
$obj_mfsemp1 = new mfs_employee ();
?>
When have constructor
<?php
$obj_con_mfsemp3 = new mfs_employee (“Abinash Grahacharya”);
?>
www.mindfiresolutions.comwww.mindfiresolutions.com |
www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires |
http://wikipedia.org/wiki/mindfire_solutions
STEP 15 ( access modifiers )
One of the fundamental principles in OOP is 'encapsulation'. The
idea is that we create cleaner better code, if you restrict access to
the data structures (properties) in our objects.
Encapsulation : Storing data/properties and functions/methods in a
single unit (class) is encapsulation. Data cannot be accessible to
the outside world and only those functions which are stored in the
class can access it.
We restrict access to class properties using something called
'access modifiers'. There are 3 access modifiers:
1. public
2. private
3. protected
'Public' is the default modifier.
www.mindfiresolutions.comwww.mindfiresolutions.com |
www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires |
http://wikipedia.org/wiki/mindfire_solutions
STEP 15 ( access modifiers ) conti...
<?php
class mfs_employee
{
var $name;
public $designation = 'SW Engineer';
protected $standard_charted_pin = '756472';
private $gps_password = 'mindfire';
function __construct($con_name)
{
$this->name = $con_name;
}
function set_name($new_name)
{
$this->name = $new_name;
}
function get_name()
{
return $this->name;
}
}
//NOTE : when ever we are using var it is treated as public
?>
www.mindfiresolutions.comwww.mindfiresolutions.com |
www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires |
STEP 16 ( Restricting access to properties )
Properties declared as 'public' have no access restrictions, meaning anyone
can access them.
When you declare a property as 'private', only the same class can access the
property.
When a property is declared 'protected', only the same class and classes
derived from that class can access the property - this has to do with inheritance
<?php
$obj_mfsemp1 = new mfs_employee (“Mindfire”);
echo $obj_mfsemp1-> get_name();
//when we try to access private or public properties outside class will through Fatal
Error
echo $obj_mfsemp1-> standard_charted_pin;
?>
www.mindfiresolutions.comwww.mindfiresolutions.com |
www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires |
http://wikipedia.org/wiki/mindfire_solutions
STEP 17 ( Restricting access to methods )
Like properties, you can control access to methods using one of the three
access modifiers:
1. public
2. protected
3. private
<?php
class mfs_employee
{
var $name;
public $designation = 'SW
Engineer';
protected $standard_charted_pin =
'756472';
private $gps_password =
'mindfire';
private function getpin()
{
return $this-
>standard_charted_pin ;
}
}
?>
Since the method getpin() is 'private', the only place you can use this method is in
the same class - typically in another method in class. If we wanted to call/use this
method directly in our PHP pages, we need to declare it as 'public'.
www.mindfiresolutions.comwww.mindfiresolutions.com |
www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires |
http://wikipedia.org/wiki/mindfire_solutions
STEP 18 ( Inheritance - reusing code the OOP way )
Inheritance is a fundamental capability/construct in OOP where you can
use one class, as the base/basis for another class … or many other
classes.
Why do it?
Doing this allows help to efficiently reuse the code found in our base class.
Say, you wanted to create a new 'sales_people' class … since we can say
that 'mfs_employee' is a type/kind of 'peoples', they will share common
properties and methods.
In this type of situation, inheritance can make our code lighter … because
we are reusing the same code in two different classes.
1. You only have to type the code out once.
2. The actual code being reused, can be reused in many classes but it is
only typed out in one place … conceptually, this is sort-of like PHP
includes().
www.mindfiresolutions.comwww.mindfiresolutions.com |
www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires |
http://wikipedia.org/wiki/mindfire_solutions
STEP 18 ( Inheritance - reusing code the OOP way ) conti..
// 'extends' is the keyword that enables
inheritance
class sales_people extends mfs_employee
{
function
__construct($employee_name)
{
$this ->
set_name($employee_name);
}
}
<?php
class mfs_employee
{
var $name;
public $designation = 'SW
Engineer';
protected $standard_charted_pin =
'756472';
private $gps_password =
'mindfire';
function __construct($con_name)
{
$this->name =
$con_name;
}
function set_name($new_name)
{
$this->name =
$new_name;
}
function get_name()
{
return $this->name;
}
}
//NOTE : when ever we are using var it is treated as public
?>
www.mindfiresolutions.comwww.mindfiresolutions.com |
www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires |
http://wikipedia.org/wiki/mindfire_solutions
STEP 19 ( Inheritance - reusing code the OOP way how to access )
Because the class 'sales_people' is based on the class ' mfs_employee ',
'sales_people' automatically has all the public and protected, properties
and methods of 'mfs_employee' class.
Notice how we are able to use set_name() in 'sales_people', even though we
did not declare that method in the 'sales_people' class. That's because we
already created set_name() in the class 'mfs_employee'.
Note: the 'sales_people' class is called children the 'base' class or the
'mfs_employee' class because it's the class that the 'sales_people' is based
on. This class hierarchy can become important down the road when our
projects become more complex.
// 'extends' is the keyword that enables
inheritance
class sales_people extends mfs_employee
{
function
__construct($employee_name)
{
$this ->
set_name($employee_name);
}
}
www.mindfiresolutions.comwww.mindfiresolutions.com |
www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires |
http://wikipedia.org/wiki/mindfire_solutions
STEP 20 ( Inheritance - reusing code the OOP way- How to access )
<?php
class mfs_employee
{
var $name;
public $designation = 'SW
Engineer';
protected $standard_charted_pin =
'756472';
private $gps_password =
'mindfire';
function __construct($con_name)
{
$this->name =
$con_name;
}
function set_name($new_name)
{
$this->name =
$new_name;
}
function get_name()
{
return $this->name;
}
}
//NOTE : when ever we are using var it is treated as public
?>
// 'extends' is the keyword that enables inheritance
class sales_people extends mfs_employee
{
function __construct($employee_name)
{
$this ->
set_name($employee_name);
}
}
//In PHP file
<?php
$sp_obj_c2 = new sales_people("class2 names");
echo $sp_obj_c2 -> get_name() ;
?>
This is a classic example of how OOP
can reduce the number of lines of code
(don't have to write the same methods
twice) while still keeping your code
modular and much easier to maintain.
www.mindfiresolutions.comwww.mindfiresolutions.com |
www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires |
http://wikipedia.org/wiki/mindfire_solutions
STEP 21 ( Overriding Methods )
Sometimes (when using inheritance,) we may need to change how a
method works from the base class.
For example, let's say set_name() method in the 'sales_people' class, have
to do something different than what it does in the 'mfs_employee' class.
We have to 'override' the ''mfs_employee' classes version of set_name(),
by declaring the same method in 'sales_people'.
// 'extends' is the keyword that enables inheritance
class sales_people extends mfs_employee
{
function __construct($employee_name)
{
$this ->
set_name($employee_name);
}
function set_name($new_name)
{
if ($new_name[0] == "S")
{
$this->name =
$new_name;
}
}
}
//In PHP file
<?php
$sp_obj_c2 = new sales_people("class2 names");
echo $sp_obj_c2 -> get_name() ;
$sp_obj_c2 = new sales_people("So Check it");
echo $sp_obj_c2 -> get_name() ;
?>
www.mindfiresolutions.comwww.mindfiresolutions.com |
www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires |
http://wikipedia.org/wiki/mindfire_solutions
STEP 22 ( Overriding Methods ) cont..
Sometimes we may need to access our base class's version of a method over
lode in the derived (sometimes called 'child') class.
In our example, we overrode the set_name() method in the 'sales_people' class.
Now We have to used the following code :
mfs_employee::set_name($new_name);
to access the parent class' (mfs_employee) version of the set_name() method
// 'extends' is the keyword that enables inheritance
class sales_people extends mfs_employee
{
function __construct($employee_name)
{
$this ->
set_name($employee_name);
}
function set_name($new_name)
{
if ($new_name == "Stefan
Sucks")
{
$this->name =
$new_name;
}
}
function set_name_old_style($new_name)
{
mfs_employee::set_name($new_name);
}
}
:: will tell to PHP to search for set_name() in
the 'base' class.
www.mindfiresolutions.comwww.mindfiresolutions.com |
www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires |
http://wikipedia.org/wiki/mindfire_solutions
STEP 22 ( Overriding Methods ) cont..
Also by using the parent keyword we can call the parent methods if it is overloaded
// 'extends' is the keyword that enables inheritance
class sales_people extends mfs_employee
{
function __construct($employee_name)
{
$this ->
set_name($employee_name);
}
function set_name($new_name)
{
if ($new_name == "Stefan
Sucks")
{
$this->name =
$new_name;
}
}
function set_name_old_style($new_name)
{
parent::set_name($new_name);
}
}
www.mindfiresolutions.comwww.mindfiresolutions.com |
www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires |
http://wikipedia.org/wiki/mindfire_solutions
Our Expertise in PHP
■ We have solid 8+ years of experience in PHP
development.
■ Our PHP development team has gained expertise in more
than 100 projects.
■ We have worked on and delivered various applications,
systems and software with PHP across various industries.
www.mindfiresolutions.comwww.mindfiresolutions.com |
www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires |
http://wikipedia.org/wiki/mindfire_solutions
Thank you for viewing the slides. Hope it did add value.
www.mindfiresolutions.comwww.mindfiresolutions.com |
www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires |
http://wikipedia.org/wiki/mindfire_solutions
Ad

More Related Content

What's hot (16)

Dependency Injection for Wordpress
Dependency Injection for WordpressDependency Injection for Wordpress
Dependency Injection for Wordpress
mtoppa
 
Introduction to PHP OOP
Introduction to PHP OOPIntroduction to PHP OOP
Introduction to PHP OOP
fakhrul hasan
 
Object Oriented Programming in PHP
Object Oriented Programming in PHPObject Oriented Programming in PHP
Object Oriented Programming in PHP
Lorna Mitchell
 
Object Oriented PHP5
Object Oriented PHP5Object Oriented PHP5
Object Oriented PHP5
Jason Austin
 
Drupal 8 templating with twig
Drupal 8 templating with twigDrupal 8 templating with twig
Drupal 8 templating with twig
Taras Omelianenko
 
Intro to OOP PHP and Github
Intro to OOP PHP and GithubIntro to OOP PHP and Github
Intro to OOP PHP and Github
Jo Erik San Jose
 
Object Oriented Programming with PHP 5 - More OOP
Object Oriented Programming with PHP 5 - More OOPObject Oriented Programming with PHP 5 - More OOP
Object Oriented Programming with PHP 5 - More OOP
Wildan Maulana
 
Class and Objects in PHP
Class and Objects in PHPClass and Objects in PHP
Class and Objects in PHP
Ramasubbu .P
 
Twig for Drupal 8 and PHP | Presented at OC Drupal
Twig for Drupal 8 and PHP | Presented at OC DrupalTwig for Drupal 8 and PHP | Presented at OC Drupal
Twig for Drupal 8 and PHP | Presented at OC Drupal
webbywe
 
XUL - Mozilla Application Framework
XUL - Mozilla Application FrameworkXUL - Mozilla Application Framework
XUL - Mozilla Application Framework
Uldis Bojars
 
Intro to OOP and new features in PHP 5.3
Intro to OOP and new features in PHP 5.3Intro to OOP and new features in PHP 5.3
Intro to OOP and new features in PHP 5.3
Adam Culp
 
tutorial54
tutorial54tutorial54
tutorial54
tutorialsruby
 
Object Oriented Programming With PHP 5 #2
Object Oriented Programming With PHP 5 #2Object Oriented Programming With PHP 5 #2
Object Oriented Programming With PHP 5 #2
Wildan Maulana
 
Scalable JavaScript Design Patterns
Scalable JavaScript Design PatternsScalable JavaScript Design Patterns
Scalable JavaScript Design Patterns
Addy Osmani
 
D7 entities fields
D7 entities fieldsD7 entities fields
D7 entities fields
cyberswat
 
Oop concepts in python
Oop concepts in pythonOop concepts in python
Oop concepts in python
baabtra.com - No. 1 supplier of quality freshers
 
Dependency Injection for Wordpress
Dependency Injection for WordpressDependency Injection for Wordpress
Dependency Injection for Wordpress
mtoppa
 
Introduction to PHP OOP
Introduction to PHP OOPIntroduction to PHP OOP
Introduction to PHP OOP
fakhrul hasan
 
Object Oriented Programming in PHP
Object Oriented Programming in PHPObject Oriented Programming in PHP
Object Oriented Programming in PHP
Lorna Mitchell
 
Object Oriented PHP5
Object Oriented PHP5Object Oriented PHP5
Object Oriented PHP5
Jason Austin
 
Drupal 8 templating with twig
Drupal 8 templating with twigDrupal 8 templating with twig
Drupal 8 templating with twig
Taras Omelianenko
 
Intro to OOP PHP and Github
Intro to OOP PHP and GithubIntro to OOP PHP and Github
Intro to OOP PHP and Github
Jo Erik San Jose
 
Object Oriented Programming with PHP 5 - More OOP
Object Oriented Programming with PHP 5 - More OOPObject Oriented Programming with PHP 5 - More OOP
Object Oriented Programming with PHP 5 - More OOP
Wildan Maulana
 
Class and Objects in PHP
Class and Objects in PHPClass and Objects in PHP
Class and Objects in PHP
Ramasubbu .P
 
Twig for Drupal 8 and PHP | Presented at OC Drupal
Twig for Drupal 8 and PHP | Presented at OC DrupalTwig for Drupal 8 and PHP | Presented at OC Drupal
Twig for Drupal 8 and PHP | Presented at OC Drupal
webbywe
 
XUL - Mozilla Application Framework
XUL - Mozilla Application FrameworkXUL - Mozilla Application Framework
XUL - Mozilla Application Framework
Uldis Bojars
 
Intro to OOP and new features in PHP 5.3
Intro to OOP and new features in PHP 5.3Intro to OOP and new features in PHP 5.3
Intro to OOP and new features in PHP 5.3
Adam Culp
 
Object Oriented Programming With PHP 5 #2
Object Oriented Programming With PHP 5 #2Object Oriented Programming With PHP 5 #2
Object Oriented Programming With PHP 5 #2
Wildan Maulana
 
Scalable JavaScript Design Patterns
Scalable JavaScript Design PatternsScalable JavaScript Design Patterns
Scalable JavaScript Design Patterns
Addy Osmani
 
D7 entities fields
D7 entities fieldsD7 entities fields
D7 entities fields
cyberswat
 

Viewers also liked (15)

Windows Vista Tour
Windows Vista TourWindows Vista Tour
Windows Vista Tour
Biswadip Goswami
 
EH Newsletter JUNE
EH Newsletter JUNEEH Newsletter JUNE
EH Newsletter JUNE
Nicole Garrett
 
sistemas operativos
sistemas operativossistemas operativos
sistemas operativos
ronald orellana
 
Cristina sambingo ff183-web2.0_pinterest
Cristina sambingo ff183-web2.0_pinterestCristina sambingo ff183-web2.0_pinterest
Cristina sambingo ff183-web2.0_pinterest
Sambingo
 
Latency vs everything
Latency vs everythingLatency vs everything
Latency vs everything
Ori Pekelman
 
RequireJs + angularAMD
RequireJs + angularAMDRequireJs + angularAMD
RequireJs + angularAMD
Ismael Costa
 
Cardio alex 2016-scientific-program-samir rafla
Cardio alex 2016-scientific-program-samir raflaCardio alex 2016-scientific-program-samir rafla
Cardio alex 2016-scientific-program-samir rafla
Alexandria University, Egypt
 
qauality assurance
qauality assuranceqauality assurance
qauality assurance
Abduladhem Ali
 
Teaching Kids Programming for Developers
Teaching Kids Programming for DevelopersTeaching Kids Programming for Developers
Teaching Kids Programming for Developers
Lynn Langit
 
Fragebogen über den Einsatz von Blechdosen bei Werbeagenturen
Fragebogen über den Einsatz von Blechdosen bei WerbeagenturenFragebogen über den Einsatz von Blechdosen bei Werbeagenturen
Fragebogen über den Einsatz von Blechdosen bei Werbeagenturen
Metalldose und Metallverpackung
 
Manejo dos Efeitos Colaterais - Lenira Nunes
Manejo dos Efeitos Colaterais - Lenira NunesManejo dos Efeitos Colaterais - Lenira Nunes
Manejo dos Efeitos Colaterais - Lenira Nunes
Oncoguia
 
A mágica por trás dos aplicativos ( Api com o Laravel )
A mágica por trás dos aplicativos ( Api com o Laravel )A mágica por trás dos aplicativos ( Api com o Laravel )
A mágica por trás dos aplicativos ( Api com o Laravel )
Michael Douglas
 
Php vs asp
Php vs aspPhp vs asp
Php vs asp
umesh patil
 
O que é
O que é O que é
O que é
Guilherme Novita Garcia
 
Building a data warehouse with AWS Redshift, Matillion and Yellowfin
Building a data warehouse with AWS Redshift, Matillion and YellowfinBuilding a data warehouse with AWS Redshift, Matillion and Yellowfin
Building a data warehouse with AWS Redshift, Matillion and Yellowfin
Lynn Langit
 
Cristina sambingo ff183-web2.0_pinterest
Cristina sambingo ff183-web2.0_pinterestCristina sambingo ff183-web2.0_pinterest
Cristina sambingo ff183-web2.0_pinterest
Sambingo
 
Latency vs everything
Latency vs everythingLatency vs everything
Latency vs everything
Ori Pekelman
 
RequireJs + angularAMD
RequireJs + angularAMDRequireJs + angularAMD
RequireJs + angularAMD
Ismael Costa
 
Teaching Kids Programming for Developers
Teaching Kids Programming for DevelopersTeaching Kids Programming for Developers
Teaching Kids Programming for Developers
Lynn Langit
 
Fragebogen über den Einsatz von Blechdosen bei Werbeagenturen
Fragebogen über den Einsatz von Blechdosen bei WerbeagenturenFragebogen über den Einsatz von Blechdosen bei Werbeagenturen
Fragebogen über den Einsatz von Blechdosen bei Werbeagenturen
Metalldose und Metallverpackung
 
Manejo dos Efeitos Colaterais - Lenira Nunes
Manejo dos Efeitos Colaterais - Lenira NunesManejo dos Efeitos Colaterais - Lenira Nunes
Manejo dos Efeitos Colaterais - Lenira Nunes
Oncoguia
 
A mágica por trás dos aplicativos ( Api com o Laravel )
A mágica por trás dos aplicativos ( Api com o Laravel )A mágica por trás dos aplicativos ( Api com o Laravel )
A mágica por trás dos aplicativos ( Api com o Laravel )
Michael Douglas
 
Building a data warehouse with AWS Redshift, Matillion and Yellowfin
Building a data warehouse with AWS Redshift, Matillion and YellowfinBuilding a data warehouse with AWS Redshift, Matillion and Yellowfin
Building a data warehouse with AWS Redshift, Matillion and Yellowfin
Lynn Langit
 
Ad

Similar to Oop's in php (20)

Oops in PHP
Oops in PHPOops in PHP
Oops in PHP
Mindfire Solutions
 
Oop in php tutorial
Oop in php tutorialOop in php tutorial
Oop in php tutorial
Gua Syed Al Yahya
 
Oop in php_tutorial_for_killerphp.com
Oop in php_tutorial_for_killerphp.comOop in php_tutorial_for_killerphp.com
Oop in php_tutorial_for_killerphp.com
ayandoesnotemail
 
oop_in_php_tutorial_for_killerphp.com
oop_in_php_tutorial_for_killerphp.comoop_in_php_tutorial_for_killerphp.com
oop_in_php_tutorial_for_killerphp.com
tutorialsruby
 
Oop in php_tutorial
Oop in php_tutorialOop in php_tutorial
Oop in php_tutorial
Gregory Hanis
 
Object oreinted php | OOPs
Object oreinted php | OOPsObject oreinted php | OOPs
Object oreinted php | OOPs
Ravi Bhadauria
 
Constructor and encapsulation in php
Constructor and encapsulation in phpConstructor and encapsulation in php
Constructor and encapsulation in php
SHIVANI SONI
 
Lecture-10_PHP-OOP.pptx
Lecture-10_PHP-OOP.pptxLecture-10_PHP-OOP.pptx
Lecture-10_PHP-OOP.pptx
ShaownRoy1
 
Dependency Injection for PHP
Dependency Injection for PHPDependency Injection for PHP
Dependency Injection for PHP
mtoppa
 
RESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher PecoraroRESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher Pecoraro
Christopher Pecoraro
 
Object Oriented PHP - PART-1
Object Oriented PHP - PART-1Object Oriented PHP - PART-1
Object Oriented PHP - PART-1
Jalpesh Vasa
 
tutorial54
tutorial54tutorial54
tutorial54
tutorialsruby
 
Php oop presentation
Php   oop presentationPhp   oop presentation
Php oop presentation
Mutinda Boniface
 
Php oop (1)
Php oop (1)Php oop (1)
Php oop (1)
Sudip Simkhada
 
Oops in PHP By Nyros Developer
Oops in PHP By Nyros DeveloperOops in PHP By Nyros Developer
Oops in PHP By Nyros Developer
Nyros Technologies
 
Oops concepts in php
Oops concepts in phpOops concepts in php
Oops concepts in php
CPD INDIA
 
c91632a4-2e92-4edf-b750-358da15ed1b1.pptx
c91632a4-2e92-4edf-b750-358da15ed1b1.pptxc91632a4-2e92-4edf-b750-358da15ed1b1.pptx
c91632a4-2e92-4edf-b750-358da15ed1b1.pptx
ajayparmeshwarmahaja
 
Embrace dynamic PHP
Embrace dynamic PHPEmbrace dynamic PHP
Embrace dynamic PHP
Paul Houle
 
Oops concept in php
Oops concept in phpOops concept in php
Oops concept in php
selvabalaji k
 
Synapseindia object oriented programming in php
Synapseindia object oriented programming in phpSynapseindia object oriented programming in php
Synapseindia object oriented programming in php
Synapseindiappsdevelopment
 
Oop in php_tutorial_for_killerphp.com
Oop in php_tutorial_for_killerphp.comOop in php_tutorial_for_killerphp.com
Oop in php_tutorial_for_killerphp.com
ayandoesnotemail
 
oop_in_php_tutorial_for_killerphp.com
oop_in_php_tutorial_for_killerphp.comoop_in_php_tutorial_for_killerphp.com
oop_in_php_tutorial_for_killerphp.com
tutorialsruby
 
Object oreinted php | OOPs
Object oreinted php | OOPsObject oreinted php | OOPs
Object oreinted php | OOPs
Ravi Bhadauria
 
Constructor and encapsulation in php
Constructor and encapsulation in phpConstructor and encapsulation in php
Constructor and encapsulation in php
SHIVANI SONI
 
Lecture-10_PHP-OOP.pptx
Lecture-10_PHP-OOP.pptxLecture-10_PHP-OOP.pptx
Lecture-10_PHP-OOP.pptx
ShaownRoy1
 
Dependency Injection for PHP
Dependency Injection for PHPDependency Injection for PHP
Dependency Injection for PHP
mtoppa
 
RESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher PecoraroRESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher Pecoraro
Christopher Pecoraro
 
Object Oriented PHP - PART-1
Object Oriented PHP - PART-1Object Oriented PHP - PART-1
Object Oriented PHP - PART-1
Jalpesh Vasa
 
Oops in PHP By Nyros Developer
Oops in PHP By Nyros DeveloperOops in PHP By Nyros Developer
Oops in PHP By Nyros Developer
Nyros Technologies
 
Oops concepts in php
Oops concepts in phpOops concepts in php
Oops concepts in php
CPD INDIA
 
c91632a4-2e92-4edf-b750-358da15ed1b1.pptx
c91632a4-2e92-4edf-b750-358da15ed1b1.pptxc91632a4-2e92-4edf-b750-358da15ed1b1.pptx
c91632a4-2e92-4edf-b750-358da15ed1b1.pptx
ajayparmeshwarmahaja
 
Embrace dynamic PHP
Embrace dynamic PHPEmbrace dynamic PHP
Embrace dynamic PHP
Paul Houle
 
Synapseindia object oriented programming in php
Synapseindia object oriented programming in phpSynapseindia object oriented programming in php
Synapseindia object oriented programming in php
Synapseindiappsdevelopment
 
Ad

More from umesh patil (20)

Ccna security
Ccna security Ccna security
Ccna security
umesh patil
 
Array in c language
Array in c languageArray in c language
Array in c language
umesh patil
 
Array in c language
Array in c language Array in c language
Array in c language
umesh patil
 
Jquery Preparation
Jquery PreparationJquery Preparation
Jquery Preparation
umesh patil
 
Cloud computing
Cloud computingCloud computing
Cloud computing
umesh patil
 
Static and dynamic polymorphism
Static and dynamic polymorphismStatic and dynamic polymorphism
Static and dynamic polymorphism
umesh patil
 
Introduction to asp .net
Introduction to asp .netIntroduction to asp .net
Introduction to asp .net
umesh patil
 
C language
C language C language
C language
umesh patil
 
Html and css presentation
Html and css presentationHtml and css presentation
Html and css presentation
umesh patil
 
Html Presentation
Html PresentationHtml Presentation
Html Presentation
umesh patil
 
Cloud computing
Cloud computingCloud computing
Cloud computing
umesh patil
 
Oops and c fundamentals
Oops and c fundamentals Oops and c fundamentals
Oops and c fundamentals
umesh patil
 
Java script
Java scriptJava script
Java script
umesh patil
 
Function in c program
Function in c programFunction in c program
Function in c program
umesh patil
 
css and wordpress
css and wordpresscss and wordpress
css and wordpress
umesh patil
 
css and wordpress
css and wordpresscss and wordpress
css and wordpress
umesh patil
 
Ccna security
Ccna security Ccna security
Ccna security
umesh patil
 
Cloud computing
Cloud computingCloud computing
Cloud computing
umesh patil
 
Cloud computing
Cloud computingCloud computing
Cloud computing
umesh patil
 
C language
C languageC language
C language
umesh patil
 
Array in c language
Array in c languageArray in c language
Array in c language
umesh patil
 
Array in c language
Array in c language Array in c language
Array in c language
umesh patil
 
Jquery Preparation
Jquery PreparationJquery Preparation
Jquery Preparation
umesh patil
 
Static and dynamic polymorphism
Static and dynamic polymorphismStatic and dynamic polymorphism
Static and dynamic polymorphism
umesh patil
 
Introduction to asp .net
Introduction to asp .netIntroduction to asp .net
Introduction to asp .net
umesh patil
 
Html and css presentation
Html and css presentationHtml and css presentation
Html and css presentation
umesh patil
 
Html Presentation
Html PresentationHtml Presentation
Html Presentation
umesh patil
 
Oops and c fundamentals
Oops and c fundamentals Oops and c fundamentals
Oops and c fundamentals
umesh patil
 
Function in c program
Function in c programFunction in c program
Function in c program
umesh patil
 
css and wordpress
css and wordpresscss and wordpress
css and wordpress
umesh patil
 
css and wordpress
css and wordpresscss and wordpress
css and wordpress
umesh patil
 

Recently uploaded (20)

K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 AccountingHow to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
Celine George
 
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Library Association of Ireland
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
SPRING FESTIVITIES - UK AND USA -
SPRING FESTIVITIES - UK AND USA            -SPRING FESTIVITIES - UK AND USA            -
SPRING FESTIVITIES - UK AND USA -
Colégio Santa Teresinha
 
Political History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptxPolitical History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
Unit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdfUnit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdf
KanchanPatil34
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...
Sandeep Swamy
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACYUNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
DR.PRISCILLA MARY J
 
Anti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptxAnti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptx
Mayuri Chavan
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 AccountingHow to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
Celine George
 
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Library Association of Ireland
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
Unit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdfUnit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdf
KanchanPatil34
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...
Sandeep Swamy
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACYUNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
DR.PRISCILLA MARY J
 
Anti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptxAnti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptx
Mayuri Chavan
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 

Oop's in php

  • 2. PHP 4, PHP 5 & PHP 6 ■ There are substantial differences between PHP 4 and PHP 5. Most of the hype was around the new object model, which was completely rewritten in PHP5. The PHP 5 version is much more complete, and performs much better as well. In PHP 4, objects were really just primitive data types, and were referenced by value. In an attempt to retain as much backward compatibility as possible in PHP 5 allows compatibility with the version 4 methods. ■ With the release of PHP 5 in 2004, PHP programmers finally had the power to code like the Java and C#, PHP finally had a complete OOP infrastructure. ■ PHP 6 has more features of object Oriented Concepts.
  • 3. Step by Step Process ■ The difference between building a PHP application the old fashioned (procedural) way versus the OOP way. ■ What the basic OOP principles are, and how to use them in PHP? ■ When to use OOP in your PHP scripts? www.mindfiresolutions.comwww.mindfiresolutions.com | www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires | http://wikipedia.org/wiki/mindfire_solutions
  • 4. Object Oriented PHP How to develop a OO PHP ?? to get into this we are going to divide the process into 22 steps by which we can get a basic idea to develop an application in OOP Concepts. STEP 1 First lets create 2 PHP files index.php class_lib.php OOP is all about creating modular code, so our object oriented PHP code will be contained in dedicated files that we will then insert into our normal PHP page using PHP 'includes'. In this case, all our OO PHP code will be in the PHP file: class_lib.php In OOP codes revolves around a 'class', Classes are the templates that are used to define objects. STEP 2 Create a simple PHP class (in class_lib.php) Instead of having a bunch of functions, variables and code floating around, to design our PHP scripts in the OOP way, we need to create our own classes. keyword 'class' www.mindfiresolutions.comwww.mindfiresolutions.com | www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires | http://wikipedia.org/wiki/mindfire_solutions
  • 5. STEP 2 ( conti ...) <?php class classname { } ?> STEP 3 (add data to your class) Classes are the blueprints for php objects. One of the big differences between functions and classes is that a class contains both data (variables) and functions that form a package called an: 'object'. When you create a variable inside a class, it is called a 'property'. <?php class classname { // var $name is called as properties of class var keyword var $name; } ?> www.mindfiresolutions.comwww.mindfiresolutions.com | www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires | http://wikipedia.org/wiki/mindfire_solutions
  • 6. STEP 4 (add functions/methods to your class) Functions also referred by different name when created inside a class - they are called 'methods'. A class's methods are used to manipulate its own data / properties. <?php class mfs_employee { var $name; function set_name($new_name) { $this->name = $new_name; } function get_name() { return $this->name; } } ?> www.mindfiresolutions.comwww.mindfiresolutions.com | www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires | http://wikipedia.org/wiki/mindfire_solutions
  • 7. STEP 5 (getter and setter functions) We've created two interesting functions/methods: get_name() and set_name(). These methods follow a common OOP convention that you see in many languages (including Java and Ruby) - where you create methods to 'set' and 'get' properties in a class. NOTE : Another convention (a naming convention,) is that getter and setter names should match the property names. This way, when other PHP programmers want to use your objects, they will know that if you have a method/function called 'set_name()', there will be a property/variable called 'name'. <?php class mfs_employee { var $name; function set_name($new_name) { $this->name = $new_name; } function get_name() { return $this- >name; } } ?> www.mindfiresolutions.comwww.mindfiresolutions.com | www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires | http://wikipedia.org/wiki/mindfire_solutions
  • 8. STEP 6 (The '$this' variable) $this->name = $new_name; $this is a built-in variable which points to the current object. Or in other words, $this is a special self-referencing variable. We use $this to access properties and to call other methods of the current class. STEP 7 (Use our class in our main PHP page : index.php ) We should not create the PHP classes in our main page, else it will break the main purpose of building applications in OOP. So in index.php include the file ( class_lib.php ) <?php include('class_lib.php'); ?> www.mindfiresolutions.comwww.mindfiresolutions.com | www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires | http://wikipedia.org/wiki/mindfire_solutions
  • 9. STEP 8 ( Instantiate/create your object ) Classes are the blueprints/templates of php objects. Classes don't actually become objects until you do something called: instantiation. When you instantiate a class, you create an instance of it ... thus creating the object. In other words, instantiation is the process of creating an instance of an object in memory. What memory? The server's memory of course! <?php $obj_mfsemp = new mfs_employee(); ?> Note: The variable $obj_mfsemp becomes a handle/reference to our newly created mfs_employee class. It is a 'handle', because we will use $obj_mfsemp to control and use the mfs_employee class. www.mindfiresolutions.comwww.mindfiresolutions.com | www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires | http://wikipedia.org/wiki/mindfire_solutions
  • 10. STEP 9 ( new keyword ) To create an object out of a class, you need to use the 'new' keyword. When creating/instantiating a class, we can optionally add brackets to the class name, as below example. To be clear, we can see in the code below how we create multiple objects from the same class. From the PHP's engine point of view, each object is its own entity. <?php $obj_mfsemp1 = new mfs_employee (); $obj_mfsemp2 = new mfs_employee ; ?> www.mindfiresolutions.comwww.mindfiresolutions.com | www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires | http://wikipedia.org/wiki/mindfire_solutions
  • 11. STEP 10 ( Set an objects properties ) Now that we've created/instantiated our two separate 'mfs_employee' objects, we can set their properties using the methods (the setters) we created. Please keep in mind that though both our mfs_employee objects ($obj_mfsemp1 and $obj_mfsemp2) are based on the same 'mfs_employee' class, as far as php is concerned, they are totally different objects. <?php $obj_mfsemp1 = new mfs_employee (); $obj_mfsemp2 = new mfs_employee ; $obj_mfsemp1->set_name("Abinash Grahacharya"); $obj_mfsemp2->set_name("Amitabh Pattnaik"); ?> www.mindfiresolutions.comwww.mindfiresolutions.com | www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires | http://wikipedia.org/wiki/mindfire_solutions
  • 12. STEP 11 ( Accessing an object's data ) Now we use the getter methods to access the data held in our objects … this is the same data we inserted into our objects using the setter methods. When accessing methods and properties of a class, we use the arrow (->) operator. <?php $obj_mfsemp1 = new mfs_employee (); $obj_mfsemp2 = new mfs_employee ; //setting values in the object $obj_mfsemp1->set_name("Abinash Grahacharya"); $obj_mfsemp2->set_name("Amitabh Pattnaik"); //getting each values from the object echo $obj_mfsemp1 -> get_name(); echo "<br />"; echo $obj_mfsemp2 -> get_name(); ?> www.mindfiresolutions.comwww.mindfiresolutions.com | www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires | http://wikipedia.org/wiki/mindfire_solutions
  • 13. In this short period of time, we have covered Designed a PHP class. Generate/created a couple of objects based on your class. Inserted data into your objects. Retrieved data from your objects. Lets now focus on PHP OBJECT. www.mindfiresolutions.comwww.mindfiresolutions.com | www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires | http://wikipedia.org/wiki/mindfire_solutions
  • 14. STEP 12 ( Directly accessing properties - don't do it! ) We don't have to use methods to access objects properties; you can directly get to them using the arrow operator (->) and the name of the variable. For example: with the property $name (in object $obj_mfsemp1,) we can get its' value like : <?php echo $obj_mfsemp1->name; ?> NOTE : Though doable, it is considered bad practice to do it because it can lead to trouble down the road. We should use getter methods instead. www.mindfiresolutions.comwww.mindfiresolutions.com | www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires | http://wikipedia.org/wiki/mindfire_solutions
  • 15. STEP 13 ( Constructor ) All objects can have a special built-in method called a 'constructor'. Constructors allow you to initialize your object's properties (give values to properties) when we instantiate (create) an object. Note: If you create a __construct() function PHP will automatically call the __construct() method/function when you create an object from your class. The 'construct' method starts with two underscores (__) and the word 'construct'. <?php class mfs_employee { var $name; function __construct($con_name) { $this->name = $con_name; } function set_name($new_name) { $this->name = $new_name; } function get_name() { return $this- >name; } } ?> www.mindfiresolutions.comwww.mindfiresolutions.com | www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires | http://wikipedia.org/wiki/mindfire_solutions
  • 16. STEP 14 ( Create an object with a constructor ) Now that we've created a constructor method, we can provide a value for the $name property when we create our objects for the class mfs_employee. We 'feed' the constructor method by providing a list of arguments (like we do with a function) after the class name at the time of object declaration. Not a constructor <?php $obj_mfsemp1 = new mfs_employee (); ?> When have constructor <?php $obj_con_mfsemp3 = new mfs_employee (“Abinash Grahacharya”); ?> www.mindfiresolutions.comwww.mindfiresolutions.com | www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires | http://wikipedia.org/wiki/mindfire_solutions
  • 17. STEP 15 ( access modifiers ) One of the fundamental principles in OOP is 'encapsulation'. The idea is that we create cleaner better code, if you restrict access to the data structures (properties) in our objects. Encapsulation : Storing data/properties and functions/methods in a single unit (class) is encapsulation. Data cannot be accessible to the outside world and only those functions which are stored in the class can access it. We restrict access to class properties using something called 'access modifiers'. There are 3 access modifiers: 1. public 2. private 3. protected 'Public' is the default modifier. www.mindfiresolutions.comwww.mindfiresolutions.com | www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires | http://wikipedia.org/wiki/mindfire_solutions
  • 18. STEP 15 ( access modifiers ) conti... <?php class mfs_employee { var $name; public $designation = 'SW Engineer'; protected $standard_charted_pin = '756472'; private $gps_password = 'mindfire'; function __construct($con_name) { $this->name = $con_name; } function set_name($new_name) { $this->name = $new_name; } function get_name() { return $this->name; } } //NOTE : when ever we are using var it is treated as public ?> www.mindfiresolutions.comwww.mindfiresolutions.com | www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires |
  • 19. STEP 16 ( Restricting access to properties ) Properties declared as 'public' have no access restrictions, meaning anyone can access them. When you declare a property as 'private', only the same class can access the property. When a property is declared 'protected', only the same class and classes derived from that class can access the property - this has to do with inheritance <?php $obj_mfsemp1 = new mfs_employee (“Mindfire”); echo $obj_mfsemp1-> get_name(); //when we try to access private or public properties outside class will through Fatal Error echo $obj_mfsemp1-> standard_charted_pin; ?> www.mindfiresolutions.comwww.mindfiresolutions.com | www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires | http://wikipedia.org/wiki/mindfire_solutions
  • 20. STEP 17 ( Restricting access to methods ) Like properties, you can control access to methods using one of the three access modifiers: 1. public 2. protected 3. private <?php class mfs_employee { var $name; public $designation = 'SW Engineer'; protected $standard_charted_pin = '756472'; private $gps_password = 'mindfire'; private function getpin() { return $this- >standard_charted_pin ; } } ?> Since the method getpin() is 'private', the only place you can use this method is in the same class - typically in another method in class. If we wanted to call/use this method directly in our PHP pages, we need to declare it as 'public'. www.mindfiresolutions.comwww.mindfiresolutions.com | www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires | http://wikipedia.org/wiki/mindfire_solutions
  • 21. STEP 18 ( Inheritance - reusing code the OOP way ) Inheritance is a fundamental capability/construct in OOP where you can use one class, as the base/basis for another class … or many other classes. Why do it? Doing this allows help to efficiently reuse the code found in our base class. Say, you wanted to create a new 'sales_people' class … since we can say that 'mfs_employee' is a type/kind of 'peoples', they will share common properties and methods. In this type of situation, inheritance can make our code lighter … because we are reusing the same code in two different classes. 1. You only have to type the code out once. 2. The actual code being reused, can be reused in many classes but it is only typed out in one place … conceptually, this is sort-of like PHP includes(). www.mindfiresolutions.comwww.mindfiresolutions.com | www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires | http://wikipedia.org/wiki/mindfire_solutions
  • 22. STEP 18 ( Inheritance - reusing code the OOP way ) conti.. // 'extends' is the keyword that enables inheritance class sales_people extends mfs_employee { function __construct($employee_name) { $this -> set_name($employee_name); } } <?php class mfs_employee { var $name; public $designation = 'SW Engineer'; protected $standard_charted_pin = '756472'; private $gps_password = 'mindfire'; function __construct($con_name) { $this->name = $con_name; } function set_name($new_name) { $this->name = $new_name; } function get_name() { return $this->name; } } //NOTE : when ever we are using var it is treated as public ?> www.mindfiresolutions.comwww.mindfiresolutions.com | www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires | http://wikipedia.org/wiki/mindfire_solutions
  • 23. STEP 19 ( Inheritance - reusing code the OOP way how to access ) Because the class 'sales_people' is based on the class ' mfs_employee ', 'sales_people' automatically has all the public and protected, properties and methods of 'mfs_employee' class. Notice how we are able to use set_name() in 'sales_people', even though we did not declare that method in the 'sales_people' class. That's because we already created set_name() in the class 'mfs_employee'. Note: the 'sales_people' class is called children the 'base' class or the 'mfs_employee' class because it's the class that the 'sales_people' is based on. This class hierarchy can become important down the road when our projects become more complex. // 'extends' is the keyword that enables inheritance class sales_people extends mfs_employee { function __construct($employee_name) { $this -> set_name($employee_name); } } www.mindfiresolutions.comwww.mindfiresolutions.com | www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires | http://wikipedia.org/wiki/mindfire_solutions
  • 24. STEP 20 ( Inheritance - reusing code the OOP way- How to access ) <?php class mfs_employee { var $name; public $designation = 'SW Engineer'; protected $standard_charted_pin = '756472'; private $gps_password = 'mindfire'; function __construct($con_name) { $this->name = $con_name; } function set_name($new_name) { $this->name = $new_name; } function get_name() { return $this->name; } } //NOTE : when ever we are using var it is treated as public ?> // 'extends' is the keyword that enables inheritance class sales_people extends mfs_employee { function __construct($employee_name) { $this -> set_name($employee_name); } } //In PHP file <?php $sp_obj_c2 = new sales_people("class2 names"); echo $sp_obj_c2 -> get_name() ; ?> This is a classic example of how OOP can reduce the number of lines of code (don't have to write the same methods twice) while still keeping your code modular and much easier to maintain. www.mindfiresolutions.comwww.mindfiresolutions.com | www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires | http://wikipedia.org/wiki/mindfire_solutions
  • 25. STEP 21 ( Overriding Methods ) Sometimes (when using inheritance,) we may need to change how a method works from the base class. For example, let's say set_name() method in the 'sales_people' class, have to do something different than what it does in the 'mfs_employee' class. We have to 'override' the ''mfs_employee' classes version of set_name(), by declaring the same method in 'sales_people'. // 'extends' is the keyword that enables inheritance class sales_people extends mfs_employee { function __construct($employee_name) { $this -> set_name($employee_name); } function set_name($new_name) { if ($new_name[0] == "S") { $this->name = $new_name; } } } //In PHP file <?php $sp_obj_c2 = new sales_people("class2 names"); echo $sp_obj_c2 -> get_name() ; $sp_obj_c2 = new sales_people("So Check it"); echo $sp_obj_c2 -> get_name() ; ?> www.mindfiresolutions.comwww.mindfiresolutions.com | www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires | http://wikipedia.org/wiki/mindfire_solutions
  • 26. STEP 22 ( Overriding Methods ) cont.. Sometimes we may need to access our base class's version of a method over lode in the derived (sometimes called 'child') class. In our example, we overrode the set_name() method in the 'sales_people' class. Now We have to used the following code : mfs_employee::set_name($new_name); to access the parent class' (mfs_employee) version of the set_name() method // 'extends' is the keyword that enables inheritance class sales_people extends mfs_employee { function __construct($employee_name) { $this -> set_name($employee_name); } function set_name($new_name) { if ($new_name == "Stefan Sucks") { $this->name = $new_name; } } function set_name_old_style($new_name) { mfs_employee::set_name($new_name); } } :: will tell to PHP to search for set_name() in the 'base' class. www.mindfiresolutions.comwww.mindfiresolutions.com | www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires | http://wikipedia.org/wiki/mindfire_solutions
  • 27. STEP 22 ( Overriding Methods ) cont.. Also by using the parent keyword we can call the parent methods if it is overloaded // 'extends' is the keyword that enables inheritance class sales_people extends mfs_employee { function __construct($employee_name) { $this -> set_name($employee_name); } function set_name($new_name) { if ($new_name == "Stefan Sucks") { $this->name = $new_name; } } function set_name_old_style($new_name) { parent::set_name($new_name); } } www.mindfiresolutions.comwww.mindfiresolutions.com | www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires | http://wikipedia.org/wiki/mindfire_solutions
  • 28. Our Expertise in PHP ■ We have solid 8+ years of experience in PHP development. ■ Our PHP development team has gained expertise in more than 100 projects. ■ We have worked on and delivered various applications, systems and software with PHP across various industries. www.mindfiresolutions.comwww.mindfiresolutions.com | www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires | http://wikipedia.org/wiki/mindfire_solutions
  • 29. Thank you for viewing the slides. Hope it did add value. www.mindfiresolutions.comwww.mindfiresolutions.com | www.twitter.com/mindfireswww.mindfiresolutions.com | www.twitter.com/mindfires | http://wikipedia.org/wiki/mindfire_solutions