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

PPT
Oops in PHP
PDF
OOP in PHP
PDF
A Gentle Introduction To Object Oriented Php
PPT
Class 7 - PHP Object Oriented Programming
PPT
Php Oop
PDF
Object Oriented Programming with PHP 5 - More OOP
PPT
Class and Objects in PHP
Oops in PHP
OOP in PHP
A Gentle Introduction To Object Oriented Php
Class 7 - PHP Object Oriented Programming
Php Oop
Object Oriented Programming with PHP 5 - More OOP
Class and Objects in PHP

What's hot (20)

PPT
Oops in PHP By Nyros Developer
PDF
Object Oriented Programming in PHP
PPTX
Oops in php
PPTX
Object oreinted php | OOPs
PDF
Intermediate OOP in PHP
PPT
PHP- Introduction to Object Oriented PHP
ZIP
Object Oriented PHP5
PPT
Oops concepts in php
PPTX
Php oop presentation
PPTX
Object oriented programming in php 5
PDF
09 Object Oriented Programming in PHP #burningkeyboards
PPTX
Intro to OOP PHP and Github
PPTX
Introduction to PHP OOP
PPT
Introduction to OOP with PHP
PPT
PHP - Introduction to Object Oriented Programming with PHP
PPTX
Basics of Object Oriented Programming in Python
PPT
Synapseindia object oriented programming in php
PPT
Intro to OOP and new features in PHP 5.3
PPTX
FFW Gabrovo PMG - PHP OOP Part 3
Oops in PHP By Nyros Developer
Object Oriented Programming in PHP
Oops in php
Object oreinted php | OOPs
Intermediate OOP in PHP
PHP- Introduction to Object Oriented PHP
Object Oriented PHP5
Oops concepts in php
Php oop presentation
Object oriented programming in php 5
09 Object Oriented Programming in PHP #burningkeyboards
Intro to OOP PHP and Github
Introduction to PHP OOP
Introduction to OOP with PHP
PHP - Introduction to Object Oriented Programming with PHP
Basics of Object Oriented Programming in Python
Synapseindia object oriented programming in php
Intro to OOP and new features in PHP 5.3
FFW Gabrovo PMG - PHP OOP Part 3
Ad

Similar to Oop in-php (20)

DOCX
Oops concept in php
PDF
Oop in php_tutorial
PDF
Oop in php tutorial
PDF
oop_in_php_tutorial_for_killerphp.com
PDF
oop_in_php_tutorial_for_killerphp.com
PDF
Oop in php_tutorial_for_killerphp.com
PDF
Object Oriented PHP - PART-1
PPTX
Lecture9_OOPHP_SPring2023.pptx
PDF
Web Design & Development - Session 8
PPT
Introduction Php
PPTX
Object Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering College
PPTX
UNIT III (8).pptx
PPTX
UNIT III (8).pptx
PPTX
Lecture-10_PHP-OOP.pptx
PPT
Basic Oops concept of PHP
PPTX
Oop's in php
PPTX
PHP OOP Lecture - 01.pptx
PPTX
Php oop (1)
PPTX
Oopsinphp
PPTX
Ch8(oop)
Oops concept in php
Oop in php_tutorial
Oop in php tutorial
oop_in_php_tutorial_for_killerphp.com
oop_in_php_tutorial_for_killerphp.com
Oop in php_tutorial_for_killerphp.com
Object Oriented PHP - PART-1
Lecture9_OOPHP_SPring2023.pptx
Web Design & Development - Session 8
Introduction Php
Object Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering College
UNIT III (8).pptx
UNIT III (8).pptx
Lecture-10_PHP-OOP.pptx
Basic Oops concept of PHP
Oop's in php
PHP OOP Lecture - 01.pptx
Php oop (1)
Oopsinphp
Ch8(oop)
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