SlideShare a Scribd company logo
1 of 13
Download to read offline
INTRODUCTION TO
PHP
Prepared by
Devshri Pandya
What is PHP?
■ PHP is stands for "Hypertext Preprocessor“.
■ PHP is a widely-used, open source scripting language.
■ PHP scripts are executed on the server.
■ PHP is free to download and use.
■ PHP is a server scripting language, and a powerful tool for making dynamic and
interactive Web pages.
■ PHP files can contain text, HTML, CSS, JavaScript, and PHP code.
■ PHP code is executed on the server, and the result is returned to the browser as plain
HTML.
■ The extension of PHP file is .php.
PHP Installation
■ Find a web host with PHP and MySQL support.
■ Install a web server on your own PC, and then install PHP and MySQL.
■ You can use a xampp or Wamp Server to run PHP Programs.
■ To download Xampp visit below link.
– https://www.apachefriends.org/download.html
■ After downloading Xampp install it and start Apache web server.
Basic Syntax of PHP
■ You can put PHP script anywhere in the document.
■ A PHP script starts with <?php and ends with ?>.
■ Each php statements ends with semicolon.
■ Syntax:
<?php
php code to be execute;
?>
PHP Simple Example
■ Print hello World in PHP.
<?php
echo “Hello World”;
?>
Output:
Hello World
Comments in PHP
■ Single Line Comment:
– You can use either // or # for single line comment in PHP.
<?php
// This is a single-line comment
# This is also a single-line comment
?>
■ Multiple-line comments:
– You can use /* ……………….*/ for Multiple line comment in PHP.
PHP Output Statements
■ To print output on screen PHP provides 2 output statements echo and
print.
■ echo and print both are used for output statements but there is a small
difference between echo and print.
Comparison between echo and print
echo
■ echo is used to provide output
on the screen.
■ It has no return value.
■ Multiple parameters can be
used with echo statement.
– Example:
echo “this”, “is”, “Multiple
Parameter”;
print
■ print is used to provide output
on the screen.
■ It has return value.
■ Only one parameter is used
with print statement.
– Example:
print “this is single
Parameter”;
PHP Variables
■ Variables are used to store information.
■ In PHP variables are starts with $ sign followed by name of variable.
■ Example:
<?php
$x = 10;
echo “Value of variable = $x”;
?>
Output:
Value of variable = 10
PHP Variable Examples
■ Variable Example:
<?php Output:
$s = "Hello world"; Value of s = Hello world
$x = 50; Value of x = 50
$y = 5.5; Value of y = 5.5
echo “Value of s = $s”;
echo “<br>”;
echo “Value of x = $x”;
echo “<br>”;
echo “Value of y = $y”;
echo “<br>”;
?>
Rules for PHP Variables
■ Rules for defining PHP variables.
– Each variable name must starts with $ sign.
■ Example: $x
– Variable name must start with either letter or underscore.
■ Example: $x, $txt, $str
– Variable name not start with digit/number. In between name you can
use number but as a first letter you are not able to use number.
■ Example: $1= “Hello”; → it will generate the error.
$x1 = “Hello”; → No error will be generated.
– Variable names are case – sensitive.
■ Example: $str and $STR both have different meaning.
Theory Questions
■ Give the full form of PHP.
■ List down output statements in PHP.
■ What is difference between echo and print statements?
■ What is the use of variable?
■ Write down rules for defining variable.
Practical List
■ Write down PHP program to print Hello world on your screen.
■ Write down PHP program to list different types of variables.

More Related Content

What's hot (20)

Php by shivitomer
Php by shivitomerPhp by shivitomer
Php by shivitomer
 
PHP tutorial | ptutorial
PHP tutorial | ptutorialPHP tutorial | ptutorial
PHP tutorial | ptutorial
 
Loops PHP 04
Loops PHP 04Loops PHP 04
Loops PHP 04
 
Php variables (english)
Php variables (english)Php variables (english)
Php variables (english)
 
Php(report)
Php(report)Php(report)
Php(report)
 
Php
PhpPhp
Php
 
Control Structures In Php 2
Control Structures In Php 2Control Structures In Php 2
Control Structures In Php 2
 
PHP Loops and PHP Forms
PHP  Loops and PHP FormsPHP  Loops and PHP Forms
PHP Loops and PHP Forms
 
Php Lecture Notes
Php Lecture NotesPhp Lecture Notes
Php Lecture Notes
 
Php
PhpPhp
Php
 
Intro to php
Intro to phpIntro to php
Intro to php
 
Class 6 - PHP Web Programming
Class 6 - PHP Web ProgrammingClass 6 - PHP Web Programming
Class 6 - PHP Web Programming
 
Web technology html5 php_mysql
Web technology html5 php_mysqlWeb technology html5 php_mysql
Web technology html5 php_mysql
 
Php tutorial
Php  tutorialPhp  tutorial
Php tutorial
 
Php
PhpPhp
Php
 
PHP Programming: Intro
PHP Programming: IntroPHP Programming: Intro
PHP Programming: Intro
 
Basics PHP
Basics PHPBasics PHP
Basics PHP
 
PHP Workshop Notes
PHP Workshop NotesPHP Workshop Notes
PHP Workshop Notes
 
Data Types In PHP
Data Types In PHPData Types In PHP
Data Types In PHP
 
Chapter 02 php basic syntax
Chapter 02   php basic syntaxChapter 02   php basic syntax
Chapter 02 php basic syntax
 

Similar to Introduction to PHP

Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)Muhamad Al Imran
 
1336333055 php tutorial_from_beginner_to_master
1336333055 php tutorial_from_beginner_to_master1336333055 php tutorial_from_beginner_to_master
1336333055 php tutorial_from_beginner_to_masterjeeva indra
 
php Chapter 1.pptx
php Chapter 1.pptxphp Chapter 1.pptx
php Chapter 1.pptxHambaAbebe2
 
Php a dynamic web scripting language
Php   a dynamic web scripting languagePhp   a dynamic web scripting language
Php a dynamic web scripting languageElmer Concepcion Jr.
 
Web Development Course: PHP lecture 1
Web Development Course: PHP lecture 1Web Development Course: PHP lecture 1
Web Development Course: PHP lecture 1Gheyath M. Othman
 
Php tutorial(w3schools)
Php tutorial(w3schools)Php tutorial(w3schools)
Php tutorial(w3schools)Arjun Shanka
 
Php tutorial from_beginner_to_master
Php tutorial from_beginner_to_masterPhp tutorial from_beginner_to_master
Php tutorial from_beginner_to_masterPrinceGuru MS
 
Lecture2_IntroductionToPHP_Spring2023.pdf
Lecture2_IntroductionToPHP_Spring2023.pdfLecture2_IntroductionToPHP_Spring2023.pdf
Lecture2_IntroductionToPHP_Spring2023.pdfShaimaaMohamedGalal
 
Introduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHPIntroduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHPwahidullah mudaser
 

Similar to Introduction to PHP (20)

Php unit i
Php unit iPhp unit i
Php unit i
 
Basic of PHP
Basic of PHPBasic of PHP
Basic of PHP
 
Materi Dasar PHP
Materi Dasar PHPMateri Dasar PHP
Materi Dasar PHP
 
PHP NOTES FOR BEGGINERS
PHP NOTES FOR BEGGINERSPHP NOTES FOR BEGGINERS
PHP NOTES FOR BEGGINERS
 
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
 
WT_PHP_PART1.pdf
WT_PHP_PART1.pdfWT_PHP_PART1.pdf
WT_PHP_PART1.pdf
 
Php modul-1
Php modul-1Php modul-1
Php modul-1
 
1336333055 php tutorial_from_beginner_to_master
1336333055 php tutorial_from_beginner_to_master1336333055 php tutorial_from_beginner_to_master
1336333055 php tutorial_from_beginner_to_master
 
php Chapter 1.pptx
php Chapter 1.pptxphp Chapter 1.pptx
php Chapter 1.pptx
 
PHP
PHPPHP
PHP
 
Php a dynamic web scripting language
Php   a dynamic web scripting languagePhp   a dynamic web scripting language
Php a dynamic web scripting language
 
Web Development Course: PHP lecture 1
Web Development Course: PHP lecture 1Web Development Course: PHP lecture 1
Web Development Course: PHP lecture 1
 
Php tutorial(w3schools)
Php tutorial(w3schools)Php tutorial(w3schools)
Php tutorial(w3schools)
 
Php tutorialw3schools
Php tutorialw3schoolsPhp tutorialw3schools
Php tutorialw3schools
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
 
Php tutorial from_beginner_to_master
Php tutorial from_beginner_to_masterPhp tutorial from_beginner_to_master
Php tutorial from_beginner_to_master
 
Lecture2_IntroductionToPHP_Spring2023.pdf
Lecture2_IntroductionToPHP_Spring2023.pdfLecture2_IntroductionToPHP_Spring2023.pdf
Lecture2_IntroductionToPHP_Spring2023.pdf
 
PHP Basic & Variables
PHP Basic & VariablesPHP Basic & Variables
PHP Basic & Variables
 
Introduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHPIntroduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHP
 

Recently uploaded

Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAbhinavSharma374939
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 

Recently uploaded (20)

Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog Converter
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 

Introduction to PHP

  • 2. What is PHP? ■ PHP is stands for "Hypertext Preprocessor“. ■ PHP is a widely-used, open source scripting language. ■ PHP scripts are executed on the server. ■ PHP is free to download and use. ■ PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. ■ PHP files can contain text, HTML, CSS, JavaScript, and PHP code. ■ PHP code is executed on the server, and the result is returned to the browser as plain HTML. ■ The extension of PHP file is .php.
  • 3. PHP Installation ■ Find a web host with PHP and MySQL support. ■ Install a web server on your own PC, and then install PHP and MySQL. ■ You can use a xampp or Wamp Server to run PHP Programs. ■ To download Xampp visit below link. – https://www.apachefriends.org/download.html ■ After downloading Xampp install it and start Apache web server.
  • 4. Basic Syntax of PHP ■ You can put PHP script anywhere in the document. ■ A PHP script starts with <?php and ends with ?>. ■ Each php statements ends with semicolon. ■ Syntax: <?php php code to be execute; ?>
  • 5. PHP Simple Example ■ Print hello World in PHP. <?php echo “Hello World”; ?> Output: Hello World
  • 6. Comments in PHP ■ Single Line Comment: – You can use either // or # for single line comment in PHP. <?php // This is a single-line comment # This is also a single-line comment ?> ■ Multiple-line comments: – You can use /* ……………….*/ for Multiple line comment in PHP.
  • 7. PHP Output Statements ■ To print output on screen PHP provides 2 output statements echo and print. ■ echo and print both are used for output statements but there is a small difference between echo and print.
  • 8. Comparison between echo and print echo ■ echo is used to provide output on the screen. ■ It has no return value. ■ Multiple parameters can be used with echo statement. – Example: echo “this”, “is”, “Multiple Parameter”; print ■ print is used to provide output on the screen. ■ It has return value. ■ Only one parameter is used with print statement. – Example: print “this is single Parameter”;
  • 9. PHP Variables ■ Variables are used to store information. ■ In PHP variables are starts with $ sign followed by name of variable. ■ Example: <?php $x = 10; echo “Value of variable = $x”; ?> Output: Value of variable = 10
  • 10. PHP Variable Examples ■ Variable Example: <?php Output: $s = "Hello world"; Value of s = Hello world $x = 50; Value of x = 50 $y = 5.5; Value of y = 5.5 echo “Value of s = $s”; echo “<br>”; echo “Value of x = $x”; echo “<br>”; echo “Value of y = $y”; echo “<br>”; ?>
  • 11. Rules for PHP Variables ■ Rules for defining PHP variables. – Each variable name must starts with $ sign. ■ Example: $x – Variable name must start with either letter or underscore. ■ Example: $x, $txt, $str – Variable name not start with digit/number. In between name you can use number but as a first letter you are not able to use number. ■ Example: $1= “Hello”; → it will generate the error. $x1 = “Hello”; → No error will be generated. – Variable names are case – sensitive. ■ Example: $str and $STR both have different meaning.
  • 12. Theory Questions ■ Give the full form of PHP. ■ List down output statements in PHP. ■ What is difference between echo and print statements? ■ What is the use of variable? ■ Write down rules for defining variable.
  • 13. Practical List ■ Write down PHP program to print Hello world on your screen. ■ Write down PHP program to list different types of variables.