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 tutorialw3schools
Php tutorialw3schoolsPhp tutorialw3schools
Php tutorialw3schools
 
Php tutorial(w3schools)
Php tutorial(w3schools)Php tutorial(w3schools)
Php tutorial(w3schools)
 
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

Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
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
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 

Recently uploaded (20)

young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
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
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
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
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
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
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 

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.