SlideShare a Scribd company logo
11
Most read
15
Most read
16
Most read
B-Tech CSE 6th
13/NR/UT/CS005
Submitted by :- Shivani Soni
Submitted to :- Shivani Dhiman
 PHP is an open source , server-side scripting
language.
 PHP is used to generate dynamic web pages.
 Originally created by Rasmus Lerdorf in 1994,
the PHP reference implementation is now
produced by The PHP Group.PHP originally
stood for Personal Home Page , but it now
stands for Hypertext Preprocessor
PHP scripts reside between reserved PHP tags .
This php tags allows the programmer to embed
php scripts with in HTML pages.
 Free
 Multi OS Support(like linux,windows,OSX)
 Easier to fix problem
 Easy to understand
 Speed
 Object oriented
 Compatible with many databases(SQL,MySQL)
 Simple efficient
 Secure flexible
 familiar
 PHP is also OOP language as it also
based on the concepts of object and
classes. PHP also uses the object
oriented concepts like encapsulation ,
inheritance , polymorphism , data
abstraction and constructors.
Class-: classes are the "blueprints“ for an
object and the actual code that defines the
properties and methods . and the class is
declared with in the tags.
Objects-: An object is an instance
of a class.
Any number of instances
of a class can be created.
<?php
class pen
{
}
?>
 <?php
 Class house
 {
 Public $name=“Soni”;
 Public $age=47;
 Function hello()
 {
 Echo “Hello world”;
 }
 $h=new house();
 $g=new house();
 Echo $h->name . “is” .$h->age .”year old”;
 Echo $g->hello ()
 ?>
 The output is-:soni is 47 year old hello world
 Define:-Encapsulation is just wrapping of data in single
unit also we can say hiding the information of essential
details . Or we can say that it is the process of hiding the data
of the object from outside world and accessed to it is
restricted to members of the class.
 Example:- Let You have a mobile phone…there it some
interface which help You to interact with cell phone and you
can uses the services of mobile phone. But the actually
working in cell phone is hide. You don’t know how it works
internally.
 <?php
 class App {
 private static $_user;
 public function User( ) {
 if( $this->_user == null ) {
 $this->_user = new User();
 }
 return $this->_user;
 }
 }
 class User {
 private $_name;
 public function __construct() {
 $this->_name = “Shivani";
 }
 public function GetName() {
 return $this->_name;
 }
 }
 $app = new App();
 echo $app->User()->GetName();
 ?>
 If a class name and function name will be
similar in that case function is known as
constructor. constructor is special type of
method because its name is similar to class
name . constructor automatically calls when
object will be initializing.
 There are two types of constructor
 1) user defined constructor
 2) predefined constructor
Constructor and encapsulation in php
 Note:-here we have called testA() method but
we didn’t call A() method because it
automatically called when object is initialized.
 PHP introduce a new functionality to
define a constructor i.e __construct().
 By using this function we can define a
constructor. it is known as predefined
constructor.
 __construct() are also known as magic
function in PHP.
Constructor and encapsulation in php
Constructor and encapsulation in php
 <?php
 class BaseClass {
 function __construct()
 {
 echo "Shivanin";
 }
 }
 class SubClass extends BaseClass
 {
 function __construct()
 {
 parent::__construct();
 echo “sonin";
 }
 }
 $obj = new BaseClass();
 $obj = new SubClass();
 ?>
Constructor and encapsulation in php
Constructor and encapsulation in php

More Related Content

What's hot (20)

PPTX
UNIT-3 Servlet
ssbd6985
 
PPTX
Multiple inheritance in java3 (1).pptx
RkGupta83
 
PPTX
Tcp/ip server sockets
rajshreemuthiah
 
PPTX
OOPs in Java
Ranjith Sekar
 
PPTX
Classes objects in java
Madishetty Prathibha
 
PPSX
Php and MySQL
Tiji Thomas
 
PPT
Sql injection attack
RajKumar Rampelli
 
PDF
Python lambda functions with filter, map & reduce function
ARVIND PANDE
 
PPTX
Delegates and events in C#
Dr.Neeraj Kumar Pandey
 
PPT
DOM and SAX
Jussi Pohjolainen
 
PPTX
Session Hijacking ppt
Harsh Kevadia
 
PPTX
SQL Injections - A Powerpoint Presentation
Rapid Purple
 
PDF
Methods in Java
Jussi Pohjolainen
 
PPTX
Introduction to php
shanmukhareddy dasi
 
PPTX
Sql injection - security testing
Napendra Singh
 
PPT
Role based access control - RBAC
Ajit Dadresa
 
PPT
Secure shell ppt
sravya raju
 
PPTX
Event handling
swapnac12
 
PPTX
Web application attacks
hruth
 
PPT
Java interfaces
Raja Sekhar
 
UNIT-3 Servlet
ssbd6985
 
Multiple inheritance in java3 (1).pptx
RkGupta83
 
Tcp/ip server sockets
rajshreemuthiah
 
OOPs in Java
Ranjith Sekar
 
Classes objects in java
Madishetty Prathibha
 
Php and MySQL
Tiji Thomas
 
Sql injection attack
RajKumar Rampelli
 
Python lambda functions with filter, map & reduce function
ARVIND PANDE
 
Delegates and events in C#
Dr.Neeraj Kumar Pandey
 
DOM and SAX
Jussi Pohjolainen
 
Session Hijacking ppt
Harsh Kevadia
 
SQL Injections - A Powerpoint Presentation
Rapid Purple
 
Methods in Java
Jussi Pohjolainen
 
Introduction to php
shanmukhareddy dasi
 
Sql injection - security testing
Napendra Singh
 
Role based access control - RBAC
Ajit Dadresa
 
Secure shell ppt
sravya raju
 
Event handling
swapnac12
 
Web application attacks
hruth
 
Java interfaces
Raja Sekhar
 

Viewers also liked (20)

PPT
PHP
sometech
 
ODP
Php variables (english)
Mahmoud Masih Tehrani
 
PPTX
OOPS Characteristics (With Examples in PHP)
baabtra.com - No. 1 supplier of quality freshers
 
PPT
Control Structures In Php 2
Digital Insights - Digital Marketing Agency
 
ODP
Htmltag.ppt
anandha ganesh
 
PDF
Arrays in PHP
Vineet Kumar Saini
 
PPS
Execute MySQL query using command prompt
Ikhwan Krisnadi
 
PDF
What's new in PHP 7.1
Simon Jones
 
PPTX
Object Oriented Programming
Haris Bin Zahid
 
PPSX
PHP Comprehensive Overview
Mohamed Loey
 
ODP
Form Processing In Php
Harit Kothari
 
PPT
PHP variables
Siddique Ibrahim
 
PPTX
State management
Iblesoft
 
PDF
4 pillars of OOPS CONCEPT
Ajay Chimmani
 
PPSX
Execute sql query or sql command sql server using command prompt
Ikhwan Krisnadi
 
PPT
Php forms
Anne Lee
 
PPTX
Cookie and session
Aashish Ghale
 
PPTX
Constructors & destructors
ForwardBlog Enewzletter
 
PPT
Cookies and sessions
Lena Petsenchuk
 
Php variables (english)
Mahmoud Masih Tehrani
 
OOPS Characteristics (With Examples in PHP)
baabtra.com - No. 1 supplier of quality freshers
 
Control Structures In Php 2
Digital Insights - Digital Marketing Agency
 
Htmltag.ppt
anandha ganesh
 
Arrays in PHP
Vineet Kumar Saini
 
Execute MySQL query using command prompt
Ikhwan Krisnadi
 
What's new in PHP 7.1
Simon Jones
 
Object Oriented Programming
Haris Bin Zahid
 
PHP Comprehensive Overview
Mohamed Loey
 
Form Processing In Php
Harit Kothari
 
PHP variables
Siddique Ibrahim
 
State management
Iblesoft
 
4 pillars of OOPS CONCEPT
Ajay Chimmani
 
Execute sql query or sql command sql server using command prompt
Ikhwan Krisnadi
 
Php forms
Anne Lee
 
Cookie and session
Aashish Ghale
 
Constructors & destructors
ForwardBlog Enewzletter
 
Cookies and sessions
Lena Petsenchuk
 
Ad

Similar to Constructor and encapsulation in php (20)

PPTX
Introduction to PHP and MySql basics.pptx
PriyankaKupneshi
 
PPTX
Introduction to PHP OOP
fakhrul hasan
 
PPT
Synapseindia object oriented programming in php
Synapseindiappsdevelopment
 
PPTX
Lecture-10_PHP-OOP.pptx
ShaownRoy1
 
PPTX
Object oreinted php | OOPs
Ravi Bhadauria
 
PPTX
Oops in php
Gourishankar R Pujar
 
PDF
Object Oriented Programming in PHP
wahidullah mudaser
 
PPTX
PHP Fundamentals: A Comprehensive Introduction
Nilesh Valva
 
PPTX
Unit 4-6 sem 7 Web Technologies.pptx
prathameshp9922
 
PPTX
PHP in one presentation
Milad Rahimi
 
PPT
PHP- Introduction to Object Oriented PHP
Vibrant Technologies & Computers
 
ZIP
Object Oriented PHP5
Jason Austin
 
PPT
UNIT-IV WT web technology for 1st year cs
javed75
 
PPTX
Object oriented programming in php
Aashiq Kuchey
 
PPT
php introduction to the basic student web
ZahraWaheed9
 
PPTX
PHP TRAINING
gurjinderbains
 
PPTX
Only oop
anitarooge
 
PPTX
Oopsinphp
NithyaNithyav
 
PPTX
Lecture 17 - PHP-Object-Orientation.pptx
DavidLazar17
 
Introduction to PHP and MySql basics.pptx
PriyankaKupneshi
 
Introduction to PHP OOP
fakhrul hasan
 
Synapseindia object oriented programming in php
Synapseindiappsdevelopment
 
Lecture-10_PHP-OOP.pptx
ShaownRoy1
 
Object oreinted php | OOPs
Ravi Bhadauria
 
Object Oriented Programming in PHP
wahidullah mudaser
 
PHP Fundamentals: A Comprehensive Introduction
Nilesh Valva
 
Unit 4-6 sem 7 Web Technologies.pptx
prathameshp9922
 
PHP in one presentation
Milad Rahimi
 
PHP- Introduction to Object Oriented PHP
Vibrant Technologies & Computers
 
Object Oriented PHP5
Jason Austin
 
UNIT-IV WT web technology for 1st year cs
javed75
 
Object oriented programming in php
Aashiq Kuchey
 
php introduction to the basic student web
ZahraWaheed9
 
PHP TRAINING
gurjinderbains
 
Only oop
anitarooge
 
Oopsinphp
NithyaNithyav
 
Lecture 17 - PHP-Object-Orientation.pptx
DavidLazar17
 
Ad

Recently uploaded (20)

PDF
Electrical Engineer operation Supervisor
ssaruntatapower143
 
PPTX
MODULE 03 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
PDF
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
PDF
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
PPTX
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
PDF
WD2(I)-RFQ-GW-1415_ Shifting and Filling of Sand in the Pond at the WD5 Area_...
ShahadathHossain23
 
PPTX
Water Resources Engineering (CVE 728)--Slide 3.pptx
mohammedado3
 
PDF
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
PDF
3rd International Conference on Machine Learning and IoT (MLIoT 2025)
ClaraZara1
 
PPTX
Final Major project a b c d e f g h i j k l m
bharathpsnab
 
PDF
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
PPTX
Numerical-Solutions-of-Ordinary-Differential-Equations.pptx
SAMUKTHAARM
 
PPTX
Distribution reservoir and service storage pptx
dhanashree78
 
PDF
MODULE-5 notes [BCG402-CG&V] PART-B.pdf
Alvas Institute of Engineering and technology, Moodabidri
 
PPTX
OCS353 DATA SCIENCE FUNDAMENTALS- Unit 1 Introduction to Data Science
A R SIVANESH M.E., (Ph.D)
 
PPTX
Water Resources Engineering (CVE 728)--Slide 4.pptx
mohammedado3
 
PPTX
Biosensors, BioDevices, Biomediccal.pptx
AsimovRiyaz
 
PPTX
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
PDF
AN EMPIRICAL STUDY ON THE USAGE OF SOCIAL MEDIA IN GERMAN B2C-ONLINE STORES
ijait
 
PPT
New_school_Engineering_presentation_011707.ppt
VinayKumar304579
 
Electrical Engineer operation Supervisor
ssaruntatapower143
 
MODULE 03 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
WD2(I)-RFQ-GW-1415_ Shifting and Filling of Sand in the Pond at the WD5 Area_...
ShahadathHossain23
 
Water Resources Engineering (CVE 728)--Slide 3.pptx
mohammedado3
 
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
3rd International Conference on Machine Learning and IoT (MLIoT 2025)
ClaraZara1
 
Final Major project a b c d e f g h i j k l m
bharathpsnab
 
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
Numerical-Solutions-of-Ordinary-Differential-Equations.pptx
SAMUKTHAARM
 
Distribution reservoir and service storage pptx
dhanashree78
 
MODULE-5 notes [BCG402-CG&V] PART-B.pdf
Alvas Institute of Engineering and technology, Moodabidri
 
OCS353 DATA SCIENCE FUNDAMENTALS- Unit 1 Introduction to Data Science
A R SIVANESH M.E., (Ph.D)
 
Water Resources Engineering (CVE 728)--Slide 4.pptx
mohammedado3
 
Biosensors, BioDevices, Biomediccal.pptx
AsimovRiyaz
 
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
AN EMPIRICAL STUDY ON THE USAGE OF SOCIAL MEDIA IN GERMAN B2C-ONLINE STORES
ijait
 
New_school_Engineering_presentation_011707.ppt
VinayKumar304579
 

Constructor and encapsulation in php

  • 1. B-Tech CSE 6th 13/NR/UT/CS005 Submitted by :- Shivani Soni Submitted to :- Shivani Dhiman
  • 2.  PHP is an open source , server-side scripting language.  PHP is used to generate dynamic web pages.  Originally created by Rasmus Lerdorf in 1994, the PHP reference implementation is now produced by The PHP Group.PHP originally stood for Personal Home Page , but it now stands for Hypertext Preprocessor
  • 3. PHP scripts reside between reserved PHP tags . This php tags allows the programmer to embed php scripts with in HTML pages.
  • 4.  Free  Multi OS Support(like linux,windows,OSX)  Easier to fix problem  Easy to understand  Speed  Object oriented  Compatible with many databases(SQL,MySQL)  Simple efficient  Secure flexible  familiar
  • 5.  PHP is also OOP language as it also based on the concepts of object and classes. PHP also uses the object oriented concepts like encapsulation , inheritance , polymorphism , data abstraction and constructors.
  • 6. Class-: classes are the "blueprints“ for an object and the actual code that defines the properties and methods . and the class is declared with in the tags. Objects-: An object is an instance of a class. Any number of instances of a class can be created. <?php class pen { } ?>
  • 7.  <?php  Class house  {  Public $name=“Soni”;  Public $age=47;  Function hello()  {  Echo “Hello world”;  }  $h=new house();  $g=new house();  Echo $h->name . “is” .$h->age .”year old”;  Echo $g->hello ()  ?>  The output is-:soni is 47 year old hello world
  • 8.  Define:-Encapsulation is just wrapping of data in single unit also we can say hiding the information of essential details . Or we can say that it is the process of hiding the data of the object from outside world and accessed to it is restricted to members of the class.  Example:- Let You have a mobile phone…there it some interface which help You to interact with cell phone and you can uses the services of mobile phone. But the actually working in cell phone is hide. You don’t know how it works internally.
  • 9.  <?php  class App {  private static $_user;  public function User( ) {  if( $this->_user == null ) {  $this->_user = new User();  }  return $this->_user;  }  }
  • 10.  class User {  private $_name;  public function __construct() {  $this->_name = “Shivani";  }  public function GetName() {  return $this->_name;  }  }  $app = new App();  echo $app->User()->GetName();  ?>
  • 11.  If a class name and function name will be similar in that case function is known as constructor. constructor is special type of method because its name is similar to class name . constructor automatically calls when object will be initializing.  There are two types of constructor  1) user defined constructor  2) predefined constructor
  • 13.  Note:-here we have called testA() method but we didn’t call A() method because it automatically called when object is initialized.
  • 14.  PHP introduce a new functionality to define a constructor i.e __construct().  By using this function we can define a constructor. it is known as predefined constructor.  __construct() are also known as magic function in PHP.
  • 17.  <?php  class BaseClass {  function __construct()  {  echo "Shivanin";  }  }  class SubClass extends BaseClass  {  function __construct()  {  parent::__construct();  echo “sonin";  }  }  $obj = new BaseClass();  $obj = new SubClass();  ?>