SlideShare a Scribd company logo
1 of 15
NuevoThoughts Technologies
OOPs in PHP
By Shubhendu
Date:16-Mar-2013 V1
www.NuevoThoughts.com
NuevoThoughts Technologies
www.NuevoThoughts.com
Summary of what we discussed:
 What is OOP?
Why we use OOPs in PHP?
How do we use OOPs in PHP?
Where do we use OOPs in PHP?
Summary
NuevoThoughts Technologies
www.NuevoThoughts.com
What is OOP?:
 Object Oriented Programming-
Basically means Programming driven by Object
Object Oriented
Programming
Procedural Programming
Programming Languages
Code controlling data
(Code is important)
Data is to Access code
(Data is important)
NuevoThoughts Technologies
www.NuevoThoughts.com
Object Oriented Programming:
Class: Programmer defined datatype include function & variables.
Object: Individual instances , used to access variable & method.
Functions: Set of code (specific tasks).
Variables: Data
Inheritance
Class in class(parent & child class)
Polymorphism
Overloading
Abstraction
Encapsulation
Constructor
Destructor
NuevoThoughts Technologies
www.NuevoThoughts.com
Why do we use OOP in PHP:
We can use PHP both as procedural and Object oriented language.
Now, question is why we use OOP concept in PHP?:
Reasons:
Flexibility
Reduce source code by more than 99.9%.
Much easier in implementing security.
Makes coding more organized.
 Help to work in team easily.
NuevoThoughts Technologies
www.NuevoThoughts.com
Flexibility:
Easily extend our PHP code whenever we require.
Member variables & functions are easily accessible from any where in the code.
Example:
in abc.php:
class sample
{
public $var;
function sample-f()
{
some code………
}
}
in abc1.php:
<?php include abc.php
$obj=new sample();
$obj->var=738
$obj->sample-f();?>
NuevoThoughts Technologies
www.NuevoThoughts.com
Reduce Source Code by more than 99.9%:
When we create big project which require lots of files, it reduces our lots of work.
In procedural PHP when we require same variable in more than one file, we copy
paste that variable or function .
But in case of OOP PHP we just put code in class , by object we can call them.
Example: in abc.php
class s1
{
public $var;
function f1()
{
//code}
}
*in abc1.php *in abc2.php
<?php include ‘abc.php’; <?php include ‘abc.php’;
$obj=new s1();
$obj->var=“hello”;?> $obj=new s1();
$obj->var=“hi”; ?>
NuevoThoughts Technologies
www.NuevoThoughts.com
Much easier in implementing security:
Security is most vital requirement in web development.
OOPs provide security by using object, all data transferred in terms of objects.
Example:
In abc.php in abc1.php
Class a <?php
{$var; include ‘abc.php’;
public Function f1($val) $obj=new a();
{If($val==NULL) $obj->f1(“sss”);
{ echo $obj->val;
This->val=“hello1”; //$obj->f2(“123”);
}} //echo $obj->val;
Public Function f2($val) ?>
{if($val==123)
This->val=“hello2”;
}}
NuevoThoughts Technologies
www.NuevoThoughts.com
Makes coding much easier:
OOP makes coding much easier to understand and clean.
Help to work in team easily:
Its important to have same method, implementations, algorithm in team
For a project.
NuevoThoughts Technologies
www.NuevoThoughts.com
How do we use OOP in PHP?:
Step 1: Create two or more PHP files:(assuming two)
Index.php
Class.php
Step 2: Put all OOP code in class.php;
Class a()
{
$var;
Function f($val)
{
this->var=$val;
}
}
Step 3:create object and access OOP functions/variables from another file.
<?php
Include class.php;
$obj=new a();
$obj->var=“hi”;
$obj->f(“hello”);
?>
NuevoThoughts Technologies
www.NuevoThoughts.com
The Principle of Model view Controller:
INPUT->PROCESS->OUTPUT
CONTROLER->MODEL->VIEW
view
model
controller
User
uses
manipulatesupdates
sees
application
NuevoThoughts Technologies
www.NuevoThoughts.com
Model:
A model is an object representing data or even activity.
The model manages the behavior and data of the application domain.
The model is the piece that represents the state.
View:
A view is some form of visualisation of the state of the model.
The view is responsible for mapping graphics onto a device.
Controllers:
A controller offers facilities to change the state of the model.
A controller is the means by which the user interacts with the application.
NuevoThoughts Technologies
www.NuevoThoughts.com
Where do we use OOPs in PHP:
Often use for creating CMS(Content management system).
Secure application.
For big projects.
NuevoThoughts Technologies
www.NuevoThoughts.com
Summary:
PHP can be used both as procedural and Object-oriented.
OOP provides flexibility, security, easiness etc to programmer.
MVC is totally based on OOPs concept.
CMS Is designed on MVC model
NuevoThoughts Technologies
Thanks
www.NuevoThoughts.com

More Related Content

What's hot

Oops in PHP By Nyros Developer
Oops in PHP By Nyros DeveloperOops in PHP By Nyros Developer
Oops in PHP By Nyros DeveloperNyros Technologies
 
Object Oriented Programming in PHP
Object Oriented Programming in PHPObject Oriented Programming in PHP
Object Oriented Programming in PHPLorna Mitchell
 
Object oreinted php | OOPs
Object oreinted php | OOPsObject oreinted php | OOPs
Object oreinted php | OOPsRavi Bhadauria
 
Intermediate OOP in PHP
Intermediate OOP in PHPIntermediate OOP in PHP
Intermediate OOP in PHPDavid Stockton
 
Object Oriented PHP5
Object Oriented PHP5Object Oriented PHP5
Object Oriented PHP5Jason Austin
 
Oops concepts in php
Oops concepts in phpOops concepts in php
Oops concepts in phpCPD INDIA
 
Object oriented programming in php 5
Object oriented programming in php 5Object oriented programming in php 5
Object oriented programming in php 5Sayed Ahmed
 
09 Object Oriented Programming in PHP #burningkeyboards
09 Object Oriented Programming in PHP #burningkeyboards09 Object Oriented Programming in PHP #burningkeyboards
09 Object Oriented Programming in PHP #burningkeyboardsDenis Ristic
 
Intro to OOP PHP and Github
Intro to OOP PHP and GithubIntro to OOP PHP and Github
Intro to OOP PHP and GithubJo Erik San Jose
 
Introduction to PHP OOP
Introduction to PHP OOPIntroduction to PHP OOP
Introduction to PHP OOPfakhrul hasan
 
Introduction to OOP with PHP
Introduction to OOP with PHPIntroduction to OOP with PHP
Introduction to OOP with PHPMichael Peacock
 
PHP - Introduction to Object Oriented Programming with PHP
PHP -  Introduction to  Object Oriented Programming with PHPPHP -  Introduction to  Object Oriented Programming with PHP
PHP - Introduction to Object Oriented Programming with PHPVibrant Technologies & Computers
 
Basics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonBasics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonSujith Kumar
 
Synapseindia object oriented programming in php
Synapseindia object oriented programming in phpSynapseindia object oriented programming in php
Synapseindia object oriented programming in phpSynapseindiappsdevelopment
 
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.3Adam Culp
 
FFW Gabrovo PMG - PHP OOP Part 3
FFW Gabrovo PMG - PHP OOP Part 3FFW Gabrovo PMG - PHP OOP Part 3
FFW Gabrovo PMG - PHP OOP Part 3Toni Kolev
 

What's hot (20)

Oops in PHP By Nyros Developer
Oops in PHP By Nyros DeveloperOops in PHP By Nyros Developer
Oops in PHP By Nyros Developer
 
Object Oriented Programming in PHP
Object Oriented Programming in PHPObject Oriented Programming in PHP
Object Oriented Programming in PHP
 
Oops in php
Oops in phpOops in php
Oops in php
 
Object oreinted php | OOPs
Object oreinted php | OOPsObject oreinted php | OOPs
Object oreinted php | OOPs
 
Intermediate OOP in PHP
Intermediate OOP in PHPIntermediate OOP in PHP
Intermediate OOP in PHP
 
PHP- Introduction to Object Oriented PHP
PHP-  Introduction to Object Oriented PHPPHP-  Introduction to Object Oriented PHP
PHP- Introduction to Object Oriented PHP
 
Object Oriented PHP5
Object Oriented PHP5Object Oriented PHP5
Object Oriented PHP5
 
Oops concepts in php
Oops concepts in phpOops concepts in php
Oops concepts in php
 
Php oop presentation
Php   oop presentationPhp   oop presentation
Php oop presentation
 
Object oriented programming in php 5
Object oriented programming in php 5Object oriented programming in php 5
Object oriented programming in php 5
 
09 Object Oriented Programming in PHP #burningkeyboards
09 Object Oriented Programming in PHP #burningkeyboards09 Object Oriented Programming in PHP #burningkeyboards
09 Object Oriented Programming in PHP #burningkeyboards
 
Intro to OOP PHP and Github
Intro to OOP PHP and GithubIntro to OOP PHP and Github
Intro to OOP PHP and Github
 
Introduction to PHP OOP
Introduction to PHP OOPIntroduction to PHP OOP
Introduction to PHP OOP
 
Introduction to OOP with PHP
Introduction to OOP with PHPIntroduction to OOP with PHP
Introduction to OOP with PHP
 
PHP - Introduction to Object Oriented Programming with PHP
PHP -  Introduction to  Object Oriented Programming with PHPPHP -  Introduction to  Object Oriented Programming with PHP
PHP - Introduction to Object Oriented Programming with PHP
 
Basics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonBasics of Object Oriented Programming in Python
Basics of Object Oriented Programming in Python
 
Synapseindia object oriented programming in php
Synapseindia object oriented programming in phpSynapseindia object oriented programming in php
Synapseindia object oriented programming in php
 
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
 
FFW Gabrovo PMG - PHP OOP Part 3
FFW Gabrovo PMG - PHP OOP Part 3FFW Gabrovo PMG - PHP OOP Part 3
FFW Gabrovo PMG - PHP OOP Part 3
 
Introduction to php oop
Introduction to php oopIntroduction to php oop
Introduction to php oop
 

Similar to Oop in-php

JavaScript development methodology
JavaScript development methodologyJavaScript development methodology
JavaScript development methodologyAleksander Fabijan
 
Snake bites : Python for Pentesters
Snake bites : Python for PentestersSnake bites : Python for Pentesters
Snake bites : Python for PentestersAnant Shrivastava
 
PHP Unit-1 Introduction to PHP
PHP Unit-1 Introduction to PHPPHP Unit-1 Introduction to PHP
PHP Unit-1 Introduction to PHPLariya Minhaz
 
Profiling PHP - AmsterdamPHP Meetup - 2014-11-20
Profiling PHP - AmsterdamPHP Meetup - 2014-11-20Profiling PHP - AmsterdamPHP Meetup - 2014-11-20
Profiling PHP - AmsterdamPHP Meetup - 2014-11-20Dennis de Greef
 
Php interview questions
Php interview questionsPhp interview questions
Php interview questionssekar c
 
客製化的 Web api 的框架設計
客製化的 Web api 的框架設計客製化的 Web api 的框架設計
客製化的 Web api 的框架設計Gelis Wu
 
Php mysql training-in-mumbai
Php mysql training-in-mumbaiPhp mysql training-in-mumbai
Php mysql training-in-mumbaiUnmesh Baile
 
OOP-Advanced Programming with c++
OOP-Advanced Programming with c++OOP-Advanced Programming with c++
OOP-Advanced Programming with c++Mohamed Essam
 
1669609053088_oops_final.pptx
1669609053088_oops_final.pptx1669609053088_oops_final.pptx
1669609053088_oops_final.pptxPandeeswariKannan
 
GTU MCA PHP Interview Questions And Answers for freshers
GTU MCA PHP  Interview Questions And Answers for freshersGTU MCA PHP  Interview Questions And Answers for freshers
GTU MCA PHP Interview Questions And Answers for freshersTOPS Technologies
 
Constructor and encapsulation in php
Constructor and encapsulation in phpConstructor and encapsulation in php
Constructor and encapsulation in phpSHIVANI SONI
 
OpenERP Technical Memento
OpenERP Technical MementoOpenERP Technical Memento
OpenERP Technical MementoOdoo
 
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.comtutorialsruby
 
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.comtutorialsruby
 

Similar to Oop in-php (20)

Oop's in php
Oop's in php Oop's in php
Oop's in php
 
PHP Jump Start
PHP Jump StartPHP Jump Start
PHP Jump Start
 
JavaScript development methodology
JavaScript development methodologyJavaScript development methodology
JavaScript development methodology
 
Snake bites : Python for Pentesters
Snake bites : Python for PentestersSnake bites : Python for Pentesters
Snake bites : Python for Pentesters
 
PHP Unit-1 Introduction to PHP
PHP Unit-1 Introduction to PHPPHP Unit-1 Introduction to PHP
PHP Unit-1 Introduction to PHP
 
Profiling PHP - AmsterdamPHP Meetup - 2014-11-20
Profiling PHP - AmsterdamPHP Meetup - 2014-11-20Profiling PHP - AmsterdamPHP Meetup - 2014-11-20
Profiling PHP - AmsterdamPHP Meetup - 2014-11-20
 
Php interview questions
Php interview questionsPhp interview questions
Php interview questions
 
Unit 1
Unit 1Unit 1
Unit 1
 
客製化的 Web api 的框架設計
客製化的 Web api 的框架設計客製化的 Web api 的框架設計
客製化的 Web api 的框架設計
 
php
phpphp
php
 
Php mysql training-in-mumbai
Php mysql training-in-mumbaiPhp mysql training-in-mumbai
Php mysql training-in-mumbai
 
OOP-Advanced Programming with c++
OOP-Advanced Programming with c++OOP-Advanced Programming with c++
OOP-Advanced Programming with c++
 
1669609053088_oops_final.pptx
1669609053088_oops_final.pptx1669609053088_oops_final.pptx
1669609053088_oops_final.pptx
 
2009-02 Oops!
2009-02 Oops!2009-02 Oops!
2009-02 Oops!
 
GTU MCA PHP Interview Questions And Answers for freshers
GTU MCA PHP  Interview Questions And Answers for freshersGTU MCA PHP  Interview Questions And Answers for freshers
GTU MCA PHP Interview Questions And Answers for freshers
 
Constructor and encapsulation in php
Constructor and encapsulation in phpConstructor and encapsulation in php
Constructor and encapsulation in php
 
OpenERP Technical Memento
OpenERP Technical MementoOpenERP Technical Memento
OpenERP Technical Memento
 
Basic concept of OOP's
Basic concept of OOP'sBasic concept of OOP's
Basic concept of OOP's
 
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
 
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
 

Oop in-php

  • 1. NuevoThoughts Technologies OOPs in PHP By Shubhendu Date:16-Mar-2013 V1 www.NuevoThoughts.com
  • 2. NuevoThoughts Technologies www.NuevoThoughts.com Summary of what we discussed:  What is OOP? Why we use OOPs in PHP? How do we use OOPs in PHP? Where do we use OOPs in PHP? Summary
  • 3. NuevoThoughts Technologies www.NuevoThoughts.com What is OOP?:  Object Oriented Programming- Basically means Programming driven by Object Object Oriented Programming Procedural Programming Programming Languages Code controlling data (Code is important) Data is to Access code (Data is important)
  • 4. NuevoThoughts Technologies www.NuevoThoughts.com Object Oriented Programming: Class: Programmer defined datatype include function & variables. Object: Individual instances , used to access variable & method. Functions: Set of code (specific tasks). Variables: Data Inheritance Class in class(parent & child class) Polymorphism Overloading Abstraction Encapsulation Constructor Destructor
  • 5. NuevoThoughts Technologies www.NuevoThoughts.com Why do we use OOP in PHP: We can use PHP both as procedural and Object oriented language. Now, question is why we use OOP concept in PHP?: Reasons: Flexibility Reduce source code by more than 99.9%. Much easier in implementing security. Makes coding more organized.  Help to work in team easily.
  • 6. NuevoThoughts Technologies www.NuevoThoughts.com Flexibility: Easily extend our PHP code whenever we require. Member variables & functions are easily accessible from any where in the code. Example: in abc.php: class sample { public $var; function sample-f() { some code……… } } in abc1.php: <?php include abc.php $obj=new sample(); $obj->var=738 $obj->sample-f();?>
  • 7. NuevoThoughts Technologies www.NuevoThoughts.com Reduce Source Code by more than 99.9%: When we create big project which require lots of files, it reduces our lots of work. In procedural PHP when we require same variable in more than one file, we copy paste that variable or function . But in case of OOP PHP we just put code in class , by object we can call them. Example: in abc.php class s1 { public $var; function f1() { //code} } *in abc1.php *in abc2.php <?php include ‘abc.php’; <?php include ‘abc.php’; $obj=new s1(); $obj->var=“hello”;?> $obj=new s1(); $obj->var=“hi”; ?>
  • 8. NuevoThoughts Technologies www.NuevoThoughts.com Much easier in implementing security: Security is most vital requirement in web development. OOPs provide security by using object, all data transferred in terms of objects. Example: In abc.php in abc1.php Class a <?php {$var; include ‘abc.php’; public Function f1($val) $obj=new a(); {If($val==NULL) $obj->f1(“sss”); { echo $obj->val; This->val=“hello1”; //$obj->f2(“123”); }} //echo $obj->val; Public Function f2($val) ?> {if($val==123) This->val=“hello2”; }}
  • 9. NuevoThoughts Technologies www.NuevoThoughts.com Makes coding much easier: OOP makes coding much easier to understand and clean. Help to work in team easily: Its important to have same method, implementations, algorithm in team For a project.
  • 10. NuevoThoughts Technologies www.NuevoThoughts.com How do we use OOP in PHP?: Step 1: Create two or more PHP files:(assuming two) Index.php Class.php Step 2: Put all OOP code in class.php; Class a() { $var; Function f($val) { this->var=$val; } } Step 3:create object and access OOP functions/variables from another file. <?php Include class.php; $obj=new a(); $obj->var=“hi”; $obj->f(“hello”); ?>
  • 11. NuevoThoughts Technologies www.NuevoThoughts.com The Principle of Model view Controller: INPUT->PROCESS->OUTPUT CONTROLER->MODEL->VIEW view model controller User uses manipulatesupdates sees application
  • 12. NuevoThoughts Technologies www.NuevoThoughts.com Model: A model is an object representing data or even activity. The model manages the behavior and data of the application domain. The model is the piece that represents the state. View: A view is some form of visualisation of the state of the model. The view is responsible for mapping graphics onto a device. Controllers: A controller offers facilities to change the state of the model. A controller is the means by which the user interacts with the application.
  • 13. NuevoThoughts Technologies www.NuevoThoughts.com Where do we use OOPs in PHP: Often use for creating CMS(Content management system). Secure application. For big projects.
  • 14. NuevoThoughts Technologies www.NuevoThoughts.com Summary: PHP can be used both as procedural and Object-oriented. OOP provides flexibility, security, easiness etc to programmer. MVC is totally based on OOPs concept. CMS Is designed on MVC model