SlideShare a Scribd company logo
INTRODUCTION TO PHP
PREPARED BY
FAKHRUL HASAN
COMPUTER PROGRAMMER
DAFFODIL INTERNATIONAL UNIVERSITY
EXPERTISE AREA:
WEB DESIGNING, WEB DEVELOPMENT, PHP, C#, ASP.NET, MYSQLAND MS
SQL.
TOPICS
WHAT IS PHP?
HISTORY
HOW WORKS
WHAT PHP CAN DO?
WHY PHP USED?
HOW STUDENTS GET
BENEFITED
PHP – BASIC
PROGRAMMING
PHP – OBJECT ORIENTED
PROGRAMMING
GET AND POST METHOD
SESSIONS AND COOKIES
PHP (Hypertext Pre-
Processor) is a widely-used
open source scripting
language that is used for web
development.
It can be embedded in HTML
Document.
Currently, PHP support both
Procedural and OOP
WHAT IS PHP?
HISTORY
PHP/FI – Personal
Home Page –
Developed in1994
by Rasmus Lerdorf.
Support:
DBM, mSQL, and
Postgres95
databases, cookies,
user-defined
function support,
and much more.
PHP 3 – Hyper Text
Pre-Processor –
Released in 1998
Developed by Andi,
Rasmus, and Zeev.
Features:
Multiple database
support, OOP
Support
PHP 4 –
Developed by Zeev
And ANDI.
Designed based on
Zend Engine.
Released in 2000.
Support Multiple
Databases, Many Web
Servers, HTTP
Sessions etc.
PHP 5 –
Released in 2004.
Fully OOP, Support
Multiple Databases
and some advance
features.
HOW WORKS
PHP Pre-Processor
Database
Client Browser
Page Request
HTML
HTML
Passed
Put Data
Get Data
WHAT PHP CAN DO?
• Main target field of PHP.
Server Side Scripting:
• PHP scripts can run on command prompt
without server.Command Line Scripting:
• Not best. But can be developed using PHP-
GTK php extension.
Writing Desktop
Application:
WHY PHP USED?
Easy to use. Code is embedded into HTML.
Easy to built informative website, e-commerce, high-level management system and so on.
Runs on almost any web server, many databases and operating systems.
Supported Web-Servers: Apache, Microsoft IIS, Netscape Enterprise Server.
Supported Operating Systems: Mac-Os, Windows, Linux (Solaries) etc.
Database Supported: MS-SQL, MySQL, Oracle, PostgreSQL, SQLite, FilePro, dBase etc.
HOW STUDENTS GET BENEFITED WITH LEARNING
PHP
Students who learn PHP for web-development will get following
advantages
Cost Effective
Development
Easily Integration Flexible to use
Available Learning
Resources
Can easily involve in
outsourcing
Available popular
CMS
PHP – BASIC PROGRAMMING
Variables:
Variables are used to store data. PHP supports different data-type.
But it is not necessary to declare data-type. PHP uses $ sign to declare a variable.
Syntax: <?php $a = “hello php”; ?>
Arrays:
Array is a process to store multiple values to a single variable in php.
The values are identified by key.
Syntax: <?php $students = array(‘hasan’, ‘kabir’); ?> or
<?php $students = array(‘first’=>’hasan’, ‘second’=>’kabir’); ?>
PHP – BASIC PROGRAMMING
Loop:
A sequence of instructions that repeated until reached to a certain condition.
Loops in PHP: for, while, do..while and foreach.
Example:
PHP – BASIC PROGRAMMING
Functions:
Functions are special block of code which can re-use again and again.
Used to minimize code and better performance.
Basically Two Types: Built-in functions, User-defined functions.
Functions are executed, when it is called.
Sample Example:
PHP- BASIC PROGRAMMING
Conditional Statements:
Conditional Statements are used to perform different action on different decision.
Conditional Statements are if, if…else, if…..else if…..else if….else, switch…case
Example:
OBJECT ORIENTED PROGRAMMING PHP
Classes and
Objects
Methods and
Properties
Scope Inheritance
Static
methods and
properties
Constants
Abstraction
and interfaces
Overriding
Object
Iteration
Serialization
Namespaces
Concept of OOP is to move the application architecture closer to real world. The OOP features of PHP
is described below:
OBJECT ORIENTED PROGRAMMING PHP
Classes and Objects
 Classes are type of entity and objects are single units of a given class
 If human is a class, then Mr. Karim, Rahim are objects of human class.
 Examples:
CONSTRUCTOR
Each class has one constructor. Constructor is called when object is initialized.
CONSTRUCTOR
PROPERTIES
A class may have unlimited number of properties
ACCESS MODIFIER
Each property and method has access modifier/scope in PHP class. It defines who can access it.
Access modifiers are:
Public
• It can be accessed from any
outside file through object
Protected
• Protected can be accessed
by descendant class
Private
• Private can be accessed by
a class itself.
INHERITANCE
• A class can inherit another class.
• When a class inherit another class, it inherit all public an protected properties of inherited class.
But can’t inherit private property.
STATIC METHOD AND PROPERTY
 Defining static to a property or method makes them accessible without creating object.
 Class can access static property with self keyword. Outside world can access it with class name.
 Example:
CONSTANTS
Normally constants are declared in PHP with define() function.
But in a class constants are declared with const keyword and not using $ sing. Class constant
can’t be called with object.
Example:
ABSTRACT CLASS AND METHOD
Abstract class can defined with abstract keyword and can’t be instantiated.
This type of class must be used by inheritance.
Abstract class may have several abstract method.
If abstract class has abstract method definition. Child class must have the
implementation of abstract method.
ABSTRACT CLASS AND METHOD
Examples:
INTERFACE
Interfaces allow what a child class must implement.
No methods in interface have implementation.
Classes can implement interface instead of extends.
Interface can only have public method.
INTERFACES
Example:
OVERRIDING
When a class inherit another class, it can declare methods that override parent class method.
Two class method names are same, parameter may differ. An Example is following:
OBJECT ITERATION
PHP provides facility to iterate an object as item of an array. Example is following:
NAMESPACE
PHP Namespace after 5.3 version allow create class with same name in same
application or page under different namespaces. Example Code is following:
PHP – GET AND POST VARIABLE
GET and POST create an array with key and value pair, where key contains name of
the form field and value contains the value of the field.
• GET is treated as $_GET in PHP, which holds all information passed
through URL as array.
• Information sent through GET Method is visible to users.
• GET has limitation highest 2000 characters
GET
• POST is treated as $_POST in PHP, which holds all information
passed through form post as array.
• Information sent through POST Method is not visible to users.
• POST has no limitation.
POST
COOKIES
Cookie is piece of text file that web
servers can store on user’s browser.
It allows server to store information
to user machine and later retrieve it.
Can store file up to 4 kb.
Maximum 20 cookies can be stored
on user’s PC per server.
SESSIONS
Session is a mechanism to store information to be used in multiple pages on the server.
PHP Session variable holds information about a single user (browser) and it available on multiple
pages.
Basically made up of two components. Client Side Session ID and Server Side Session Data.
To use session in PHP, developer must call the function session_start(); at the top.
PHP FRAMEWORKS
Some popular frameworks of PHP are
following:
Laravel
Symfony
Code Igniter
Yii
Cake PHP
Zend
Phalcon
Popular CMS build using PHP:
Wordpress
Joomla
Drupal
Exponent CMS
Magento
PHP Nuke
QUESTIONS??

More Related Content

What's hot

Introduction to OOP with PHP
Introduction to OOP with PHPIntroduction to OOP with PHP
Introduction to OOP with PHPMichael Peacock
 
Object oriented programming in php 5
Object oriented programming in php 5Object oriented programming in php 5
Object oriented programming in php 5
Sayed Ahmed
 
Php oop presentation
Php   oop presentationPhp   oop presentation
Php oop presentation
Mutinda Boniface
 
Oops in PHP
Oops in PHPOops in PHP
Oops in PHP
Mindfire Solutions
 
OOPS Characteristics (With Examples in PHP)
OOPS Characteristics (With Examples in PHP)OOPS Characteristics (With Examples in PHP)
OOPS Characteristics (With Examples in PHP)
baabtra.com - No. 1 supplier of quality freshers
 
Oop in-php
Oop in-phpOop in-php
Oop in-phpRajesh S
 
A Gentle Introduction To Object Oriented Php
A Gentle Introduction To Object Oriented PhpA Gentle Introduction To Object Oriented Php
A Gentle Introduction To Object Oriented PhpMichael Girouard
 
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
Vibrant Technologies & Computers
 
PHP Classes and OOPS Concept
PHP Classes and OOPS ConceptPHP Classes and OOPS Concept
PHP- Introduction to Object Oriented PHP
PHP-  Introduction to Object Oriented PHPPHP-  Introduction to Object Oriented PHP
PHP- Introduction to Object Oriented PHP
Vibrant Technologies & Computers
 
Class 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented ProgrammingClass 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented Programming
Ahmed Swilam
 
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
Denis Ristic
 
Object Oriented PHP5
Object Oriented PHP5Object Oriented PHP5
Object Oriented PHP5
Jason Austin
 
Object Oriented Programming in PHP
Object Oriented Programming in PHPObject Oriented Programming in PHP
Object Oriented Programming in PHP
Lorna Mitchell
 
Oops in php
Oops in phpOops in php
Oops in php
sanjay joshi
 
Php oop (1)
Php oop (1)Php oop (1)
Php oop (1)
Sudip Simkhada
 
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 OOPWildan Maulana
 
Class and Objects in PHP
Class and Objects in PHPClass and Objects in PHP
Class and Objects in PHP
Ramasubbu .P
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#Doncho Minkov
 
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
Sujith Kumar
 

What's hot (20)

Introduction to OOP with PHP
Introduction to OOP with PHPIntroduction to OOP with PHP
Introduction to OOP with PHP
 
Object oriented programming in php 5
Object oriented programming in php 5Object oriented programming in php 5
Object oriented programming in php 5
 
Php oop presentation
Php   oop presentationPhp   oop presentation
Php oop presentation
 
Oops in PHP
Oops in PHPOops in PHP
Oops in PHP
 
OOPS Characteristics (With Examples in PHP)
OOPS Characteristics (With Examples in PHP)OOPS Characteristics (With Examples in PHP)
OOPS Characteristics (With Examples in PHP)
 
Oop in-php
Oop in-phpOop in-php
Oop in-php
 
A Gentle Introduction To Object Oriented Php
A Gentle Introduction To Object Oriented PhpA Gentle Introduction To Object Oriented Php
A Gentle Introduction To Object Oriented 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
 
PHP Classes and OOPS Concept
PHP Classes and OOPS ConceptPHP Classes and OOPS Concept
PHP Classes and OOPS Concept
 
PHP- Introduction to Object Oriented PHP
PHP-  Introduction to Object Oriented PHPPHP-  Introduction to Object Oriented PHP
PHP- Introduction to Object Oriented PHP
 
Class 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented ProgrammingClass 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented Programming
 
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
 
Object Oriented PHP5
Object Oriented PHP5Object Oriented PHP5
Object Oriented PHP5
 
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
 
Php oop (1)
Php oop (1)Php oop (1)
Php oop (1)
 
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
 
Class and Objects in PHP
Class and Objects in PHPClass and Objects in PHP
Class and Objects in PHP
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#
 
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
 

Similar to Introduction to PHP OOP

Php Interview Questions
Php Interview QuestionsPhp Interview Questions
Php Interview Questions
UmeshSingh159
 
Php notes
Php notesPhp notes
Php notes
Muthuganesh S
 
PHP web design
PHP web designPHP web design
PHP web design
Vhin Militante
 
Constructor and encapsulation in php
Constructor and encapsulation in phpConstructor and encapsulation in php
Constructor and encapsulation in php
SHIVANI SONI
 
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
TOPS Technologies
 
chapter 5 Server-Side Scripting (PHP).pdf
chapter 5 Server-Side Scripting (PHP).pdfchapter 5 Server-Side Scripting (PHP).pdf
chapter 5 Server-Side Scripting (PHP).pdf
burasyacob012
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
Taha Malampatti
 
Basics PHP
Basics PHPBasics PHP
Unit 1
Unit 1Unit 1
Hsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdfHsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdf
AAFREEN SHAIKH
 
PHP Basics
PHP BasicsPHP Basics
PHP Basics
Roohul Amin
 
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
anshkhurana01
 
WT_PHP_PART1.pdf
WT_PHP_PART1.pdfWT_PHP_PART1.pdf
WT_PHP_PART1.pdf
HambardeAtharva
 
UNIT-IV WT web technology for 1st year cs
UNIT-IV WT web technology for 1st year csUNIT-IV WT web technology for 1st year cs
UNIT-IV WT web technology for 1st year cs
javed75
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
SHARANBAJWA
 
Introduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHPIntroduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHP
wahidullah mudaser
 
Php technical presentation
Php technical presentationPhp technical presentation
Php technical presentation
dharmendra kumar dhakar
 

Similar to Introduction to PHP OOP (20)

php questions
php questions php questions
php questions
 
Php Interview Questions
Php Interview QuestionsPhp Interview Questions
Php Interview Questions
 
Php notes
Php notesPhp notes
Php notes
 
PHP web design
PHP web designPHP web design
PHP web design
 
Constructor and encapsulation in php
Constructor and encapsulation in phpConstructor and encapsulation in php
Constructor and encapsulation in php
 
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
 
chapter 5 Server-Side Scripting (PHP).pdf
chapter 5 Server-Side Scripting (PHP).pdfchapter 5 Server-Side Scripting (PHP).pdf
chapter 5 Server-Side Scripting (PHP).pdf
 
Php basics
Php basicsPhp basics
Php basics
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Basics PHP
Basics PHPBasics PHP
Basics PHP
 
Unit 1
Unit 1Unit 1
Unit 1
 
Hsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdfHsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdf
 
PHP Basics
PHP BasicsPHP Basics
PHP Basics
 
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
 
WT_PHP_PART1.pdf
WT_PHP_PART1.pdfWT_PHP_PART1.pdf
WT_PHP_PART1.pdf
 
UNIT-IV WT web technology for 1st year cs
UNIT-IV WT web technology for 1st year csUNIT-IV WT web technology for 1st year cs
UNIT-IV WT web technology for 1st year cs
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
 
Php introduction
Php introductionPhp introduction
Php introduction
 
Introduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHPIntroduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHP
 
Php technical presentation
Php technical presentationPhp technical presentation
Php technical presentation
 

Recently uploaded

CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
Intella Parts
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
Kamal Acharya
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
Kamal Acharya
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
AafreenAbuthahir2
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfCOLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
Kamal Acharya
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
MuhammadTufail242431
 

Recently uploaded (20)

CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfCOLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
 

Introduction to PHP OOP

  • 2. PREPARED BY FAKHRUL HASAN COMPUTER PROGRAMMER DAFFODIL INTERNATIONAL UNIVERSITY EXPERTISE AREA: WEB DESIGNING, WEB DEVELOPMENT, PHP, C#, ASP.NET, MYSQLAND MS SQL.
  • 3. TOPICS WHAT IS PHP? HISTORY HOW WORKS WHAT PHP CAN DO? WHY PHP USED? HOW STUDENTS GET BENEFITED PHP – BASIC PROGRAMMING PHP – OBJECT ORIENTED PROGRAMMING GET AND POST METHOD SESSIONS AND COOKIES
  • 4. PHP (Hypertext Pre- Processor) is a widely-used open source scripting language that is used for web development. It can be embedded in HTML Document. Currently, PHP support both Procedural and OOP WHAT IS PHP?
  • 5. HISTORY PHP/FI – Personal Home Page – Developed in1994 by Rasmus Lerdorf. Support: DBM, mSQL, and Postgres95 databases, cookies, user-defined function support, and much more. PHP 3 – Hyper Text Pre-Processor – Released in 1998 Developed by Andi, Rasmus, and Zeev. Features: Multiple database support, OOP Support PHP 4 – Developed by Zeev And ANDI. Designed based on Zend Engine. Released in 2000. Support Multiple Databases, Many Web Servers, HTTP Sessions etc. PHP 5 – Released in 2004. Fully OOP, Support Multiple Databases and some advance features.
  • 6. HOW WORKS PHP Pre-Processor Database Client Browser Page Request HTML HTML Passed Put Data Get Data
  • 7. WHAT PHP CAN DO? • Main target field of PHP. Server Side Scripting: • PHP scripts can run on command prompt without server.Command Line Scripting: • Not best. But can be developed using PHP- GTK php extension. Writing Desktop Application:
  • 8. WHY PHP USED? Easy to use. Code is embedded into HTML. Easy to built informative website, e-commerce, high-level management system and so on. Runs on almost any web server, many databases and operating systems. Supported Web-Servers: Apache, Microsoft IIS, Netscape Enterprise Server. Supported Operating Systems: Mac-Os, Windows, Linux (Solaries) etc. Database Supported: MS-SQL, MySQL, Oracle, PostgreSQL, SQLite, FilePro, dBase etc.
  • 9. HOW STUDENTS GET BENEFITED WITH LEARNING PHP Students who learn PHP for web-development will get following advantages Cost Effective Development Easily Integration Flexible to use Available Learning Resources Can easily involve in outsourcing Available popular CMS
  • 10. PHP – BASIC PROGRAMMING Variables: Variables are used to store data. PHP supports different data-type. But it is not necessary to declare data-type. PHP uses $ sign to declare a variable. Syntax: <?php $a = “hello php”; ?> Arrays: Array is a process to store multiple values to a single variable in php. The values are identified by key. Syntax: <?php $students = array(‘hasan’, ‘kabir’); ?> or <?php $students = array(‘first’=>’hasan’, ‘second’=>’kabir’); ?>
  • 11. PHP – BASIC PROGRAMMING Loop: A sequence of instructions that repeated until reached to a certain condition. Loops in PHP: for, while, do..while and foreach. Example:
  • 12. PHP – BASIC PROGRAMMING Functions: Functions are special block of code which can re-use again and again. Used to minimize code and better performance. Basically Two Types: Built-in functions, User-defined functions. Functions are executed, when it is called. Sample Example:
  • 13. PHP- BASIC PROGRAMMING Conditional Statements: Conditional Statements are used to perform different action on different decision. Conditional Statements are if, if…else, if…..else if…..else if….else, switch…case Example:
  • 14. OBJECT ORIENTED PROGRAMMING PHP Classes and Objects Methods and Properties Scope Inheritance Static methods and properties Constants Abstraction and interfaces Overriding Object Iteration Serialization Namespaces Concept of OOP is to move the application architecture closer to real world. The OOP features of PHP is described below:
  • 15. OBJECT ORIENTED PROGRAMMING PHP Classes and Objects  Classes are type of entity and objects are single units of a given class  If human is a class, then Mr. Karim, Rahim are objects of human class.  Examples:
  • 16. CONSTRUCTOR Each class has one constructor. Constructor is called when object is initialized.
  • 18. PROPERTIES A class may have unlimited number of properties
  • 19. ACCESS MODIFIER Each property and method has access modifier/scope in PHP class. It defines who can access it. Access modifiers are: Public • It can be accessed from any outside file through object Protected • Protected can be accessed by descendant class Private • Private can be accessed by a class itself.
  • 20. INHERITANCE • A class can inherit another class. • When a class inherit another class, it inherit all public an protected properties of inherited class. But can’t inherit private property.
  • 21. STATIC METHOD AND PROPERTY  Defining static to a property or method makes them accessible without creating object.  Class can access static property with self keyword. Outside world can access it with class name.  Example:
  • 22. CONSTANTS Normally constants are declared in PHP with define() function. But in a class constants are declared with const keyword and not using $ sing. Class constant can’t be called with object. Example:
  • 23. ABSTRACT CLASS AND METHOD Abstract class can defined with abstract keyword and can’t be instantiated. This type of class must be used by inheritance. Abstract class may have several abstract method. If abstract class has abstract method definition. Child class must have the implementation of abstract method.
  • 24. ABSTRACT CLASS AND METHOD Examples:
  • 25. INTERFACE Interfaces allow what a child class must implement. No methods in interface have implementation. Classes can implement interface instead of extends. Interface can only have public method.
  • 27. OVERRIDING When a class inherit another class, it can declare methods that override parent class method. Two class method names are same, parameter may differ. An Example is following:
  • 28. OBJECT ITERATION PHP provides facility to iterate an object as item of an array. Example is following:
  • 29. NAMESPACE PHP Namespace after 5.3 version allow create class with same name in same application or page under different namespaces. Example Code is following:
  • 30. PHP – GET AND POST VARIABLE GET and POST create an array with key and value pair, where key contains name of the form field and value contains the value of the field. • GET is treated as $_GET in PHP, which holds all information passed through URL as array. • Information sent through GET Method is visible to users. • GET has limitation highest 2000 characters GET • POST is treated as $_POST in PHP, which holds all information passed through form post as array. • Information sent through POST Method is not visible to users. • POST has no limitation. POST
  • 31. COOKIES Cookie is piece of text file that web servers can store on user’s browser. It allows server to store information to user machine and later retrieve it. Can store file up to 4 kb. Maximum 20 cookies can be stored on user’s PC per server.
  • 32. SESSIONS Session is a mechanism to store information to be used in multiple pages on the server. PHP Session variable holds information about a single user (browser) and it available on multiple pages. Basically made up of two components. Client Side Session ID and Server Side Session Data. To use session in PHP, developer must call the function session_start(); at the top.
  • 33. PHP FRAMEWORKS Some popular frameworks of PHP are following: Laravel Symfony Code Igniter Yii Cake PHP Zend Phalcon Popular CMS build using PHP: Wordpress Joomla Drupal Exponent CMS Magento PHP Nuke