SlideShare a Scribd company logo
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 (20)

PPT
Oops in PHP By Nyros Developer
Nyros Technologies
 
PDF
Object Oriented Programming in PHP
Lorna Mitchell
 
PPTX
Oops in php
sanjay joshi
 
PPTX
Object oreinted php | OOPs
Ravi Bhadauria
 
PDF
Intermediate OOP in PHP
David Stockton
 
PPT
PHP- Introduction to Object Oriented PHP
Vibrant Technologies & Computers
 
ZIP
Object Oriented PHP5
Jason Austin
 
PPT
Oops concepts in php
CPD INDIA
 
PPTX
Php oop presentation
Mutinda Boniface
 
PPTX
Object oriented programming in php 5
Sayed Ahmed
 
PDF
09 Object Oriented Programming in PHP #burningkeyboards
Denis Ristic
 
PPTX
Intro to OOP PHP and Github
Jo Erik San Jose
 
PPTX
Introduction to PHP OOP
fakhrul hasan
 
PPT
Introduction to OOP with PHP
Michael Peacock
 
PPT
PHP - Introduction to Object Oriented Programming with PHP
Vibrant Technologies & Computers
 
PPTX
Basics of Object Oriented Programming in Python
Sujith Kumar
 
PPT
Synapseindia object oriented programming in php
Synapseindiappsdevelopment
 
PPT
Intro to OOP and new features in PHP 5.3
Adam Culp
 
PPTX
FFW Gabrovo PMG - PHP OOP Part 3
Toni Kolev
 
Oops in PHP By Nyros Developer
Nyros Technologies
 
Object Oriented Programming in PHP
Lorna Mitchell
 
Oops in php
sanjay joshi
 
Object oreinted php | OOPs
Ravi Bhadauria
 
Intermediate OOP in PHP
David Stockton
 
PHP- Introduction to Object Oriented PHP
Vibrant Technologies & Computers
 
Object Oriented PHP5
Jason Austin
 
Oops concepts in php
CPD INDIA
 
Php oop presentation
Mutinda Boniface
 
Object oriented programming in php 5
Sayed Ahmed
 
09 Object Oriented Programming in PHP #burningkeyboards
Denis Ristic
 
Intro to OOP PHP and Github
Jo Erik San Jose
 
Introduction to PHP OOP
fakhrul hasan
 
Introduction to OOP with PHP
Michael Peacock
 
PHP - Introduction to Object Oriented Programming with PHP
Vibrant Technologies & Computers
 
Basics of Object Oriented Programming in Python
Sujith Kumar
 
Synapseindia object oriented programming in php
Synapseindiappsdevelopment
 
Intro to OOP and new features in PHP 5.3
Adam Culp
 
FFW Gabrovo PMG - PHP OOP Part 3
Toni Kolev
 

Similar to Oop in-php (20)

DOCX
Oops concept in php
selvabalaji k
 
PDF
Oop in php_tutorial
Gregory Hanis
 
PDF
oop_in_php_tutorial_for_killerphp.com
tutorialsruby
 
PDF
oop_in_php_tutorial_for_killerphp.com
tutorialsruby
 
PDF
Oop in php tutorial
Gua Syed Al Yahya
 
PDF
Oop in php_tutorial_for_killerphp.com
ayandoesnotemail
 
PDF
Object Oriented PHP - PART-1
Jalpesh Vasa
 
PPTX
Lecture9_OOPHP_SPring2023.pptx
ShaimaaMohamedGalal
 
PDF
Web Design & Development - Session 8
Shahrzad Peyman
 
PPT
Introduction Php
sanjay joshi
 
PPTX
Object Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering College
Dhivyaa C.R
 
PPTX
UNIT III (8).pptx
DrDhivyaaCRAssistant
 
PPTX
UNIT III (8).pptx
DrDhivyaaCRAssistant
 
PPTX
Lecture-10_PHP-OOP.pptx
ShaownRoy1
 
PPT
Basic Oops concept of PHP
Rohan Sharma
 
PPTX
Oop's in php
umesh patil
 
PPTX
PHP OOP Lecture - 01.pptx
Atikur Rahman
 
PPTX
Php oop (1)
Sudip Simkhada
 
PPTX
Oopsinphp
NithyaNithyav
 
PPTX
Ch8(oop)
Chhom Karath
 
Oops concept in php
selvabalaji k
 
Oop in php_tutorial
Gregory Hanis
 
oop_in_php_tutorial_for_killerphp.com
tutorialsruby
 
oop_in_php_tutorial_for_killerphp.com
tutorialsruby
 
Oop in php tutorial
Gua Syed Al Yahya
 
Oop in php_tutorial_for_killerphp.com
ayandoesnotemail
 
Object Oriented PHP - PART-1
Jalpesh Vasa
 
Lecture9_OOPHP_SPring2023.pptx
ShaimaaMohamedGalal
 
Web Design & Development - Session 8
Shahrzad Peyman
 
Introduction Php
sanjay joshi
 
Object Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering College
Dhivyaa C.R
 
UNIT III (8).pptx
DrDhivyaaCRAssistant
 
UNIT III (8).pptx
DrDhivyaaCRAssistant
 
Lecture-10_PHP-OOP.pptx
ShaownRoy1
 
Basic Oops concept of PHP
Rohan Sharma
 
Oop's in php
umesh patil
 
PHP OOP Lecture - 01.pptx
Atikur Rahman
 
Php oop (1)
Sudip Simkhada
 
Oopsinphp
NithyaNithyav
 
Ch8(oop)
Chhom Karath
 
Ad

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