SlideShare a Scribd company logo
PHP
      an introduction
What is PHP?


 • PHP stands for PHP: Hypertext Preprocessor

 • PHP is a server-side scripting language, which could
   be imbedded to HTML

 • PHP scripts are executed on the server

 • PHP supports many databases

 • PHP is an open source software, free to download
   and use

                                                          2
PHP Syntax

  <?php
  ….
  ?>


  <html>
       <body>
          <?php
          echo “Hello World”;
          ?>
       </body>
  </html>

                                3
Text Editors



• Dreamweaver Open as php and add code in code
  view. Use: Insert > php.
• Windows Notepad Make sure your files are saved
  with the .php extension.
• Microsoft Word is not optimal for editing PHP files.
  If you use it, you must save the file as plain text.




                                                         4
.html or .php: where

**Inline**                           **html code with echo and print*
<html>
                                    <?php
 <head>
 <title>HTML with PHP</title>        echo "<html>";
 </head>                             echo "<title>HTML with PHP</title>";
 <body>                              echo "<h1>My example</h1>";
   <h1>My Example</h1>
                                     //your php code here.
   <?php
     //your php code here            print "<i>Print works too!</i>";
   ?>
                                     echo “</html>”;
   <b>Here is some more html.</b>
   <?php                            ?>
     //your php code here
   ?>
 </body>
</html>                                                                 5
.html or .php??




     • Open new > Page type: php
     • Save as .php




                                   6
Variables


• Variables are used for storing a values, like text
   strings, numbers or arrays.
• When a variable is declared, it can be used over and
   over again in your script.
• All variables in PHP start with a $ sign symbol.
• The correct way of declaring a variable in PHP:

        $name = value;




                                                         7
Naming Rules for Variables


 • A variable name must start with a letter or an underscore
   “_”
 • A variable name can only contain alpha-numeric
   characters and underscores (a-z, A-Z, 0-9, and _ )
 • A variable name should not contain spaces. If a variable
   name is more than one word, it should be separated with
   an underscore ($my_string), or with capitalization
   ($myString)



                                                               8
The Concatenation Operator



The concatenation operator . is used to put two string together.



           <?php
             $txt1=“Hello World!”;
             $txt2=“What a nice day!”;
             echo $txt1 . “ ” . $txt2;
           ?>



                                                               9
Comments



 • Comments can be added to explain the
   PHP.

 • Single line comments start with //.

 • Multi line comments start with /* and end
   with */



                                               10
if…else Syntax

 <?php
      if (condition1)
       {code to be executed if condition1 is true};
      elseif (condition2)
       {code to be executed if condition2 is true};
      else
       {code to be executed if condition1 and condition2
             are not true};
 ?>

                                                           11
if…else Example

<?php
   $num1=10;
   $num2=20;
   if ($num1>$num2)
     echo “The first number is greater than the second.<br />”;
   elseif ($num1<$num2)
     {echo “The first number is smaller than the second.<br />”;
       echo “too bad”;
     }
   else
        echo “The first number is equal to the second.<br />”;
?>


                                                                   12
For Loop Syntax

  The for loop is used when you know in advance how
  many times the script should run.

  for (initial condition; end condition; increment)
    {
    code to be executed;
    }




                                                      13
For Loop Example


     <?php
        for ($i=0; $i<=5; $i++)
          {
           echo "The number is " . $i;
           echo “.<br />”;
           }
     ?>



                                         14
While Loop Syntax



     Initial variable;

     while (end variable)
        {
        code to be executed;

        variable increment;
        }


                               15
While Loop Example


    <php?
       $i=0;
       while ($i<=5)
       {
       echo "The number is " . $i . “.<br />”;
       $i++;
       }
    ?>


                                                 16
Function Syntax

   • need to be called in order to execute
   • Can be called multiple times with different variables

        function funname(var1, var2)
          {
          function code;
          }

        funname(var1, var2);



                                                             17
Function Example

   <?php

        function getGreeting($user){

            return “Hello, $user!”;

        }



        echo getGreeting(„Toby‟);

   ?>



                                       18
Function Example


 function caltax($num1)

    {$tax=0.0875;

     $total = $num1+($num1*$tax);

    echo "The total is $” . $total . ". <br />”;

    }

  caltax(100);



                                                   19
Works Cited




Most of the information on this PowerPoint are based
on W3Schools Online Web Tutorials PHP section.




                                                       20

More Related Content

What's hot (20)

PPT
Php(report)
Yhannah
 
PDF
Quick tour of PHP from inside
julien pauli
 
PPT
PHP POWERPOINT SLIDES
Ismail Mukiibi
 
PPT
PHP - Introduction to PHP - Mazenet Solution
Mazenetsolution
 
PPT
Introduction to PHP
Jussi Pohjolainen
 
PPTX
Basic of PHP
Nisa Soomro
 
ODP
PHP Basic
Yoeung Vibol
 
PPTX
php basics
Anmol Paul
 
PPT
PHP
sometech
 
PPT
slidesharenew1
truptitasol
 
PPT
My cool new Slideshow!
omprakash_bagrao_prdxn
 
PDF
Introduction to PHP
Devshri Pandya
 
PDF
PHP7 is coming
julien pauli
 
PDF
Profiling php5 to php7
julien pauli
 
PDF
Data Types In PHP
Mark Niebergall
 
PPT
Php i basic chapter 3
Muhamad Al Imran
 
KEY
Intermediate PHP
Bradley Holt
 
PPTX
Loops PHP 04
mohamedsaad24
 
PDF
PHP Loops and PHP Forms
M.Zalmai Rahmani
 
Php(report)
Yhannah
 
Quick tour of PHP from inside
julien pauli
 
PHP POWERPOINT SLIDES
Ismail Mukiibi
 
PHP - Introduction to PHP - Mazenet Solution
Mazenetsolution
 
Introduction to PHP
Jussi Pohjolainen
 
Basic of PHP
Nisa Soomro
 
PHP Basic
Yoeung Vibol
 
php basics
Anmol Paul
 
slidesharenew1
truptitasol
 
My cool new Slideshow!
omprakash_bagrao_prdxn
 
Introduction to PHP
Devshri Pandya
 
PHP7 is coming
julien pauli
 
Profiling php5 to php7
julien pauli
 
Data Types In PHP
Mark Niebergall
 
Php i basic chapter 3
Muhamad Al Imran
 
Intermediate PHP
Bradley Holt
 
Loops PHP 04
mohamedsaad24
 
PHP Loops and PHP Forms
M.Zalmai Rahmani
 

Viewers also liked (20)

PPTX
Week 2 HTML lists, hyperlinks, tables, and images
Rowena LI
 
PPT
Week1 Dreamweaver and Server
Rowena LI
 
PPTX
Web 2.0: its impact on library services
Rowena LI
 
PPTX
Week1 Introduction
Rowena LI
 
PPT
Week3 css
Rowena LI
 
PPT
Hybrid in 5 minutes
Rowena LI
 
PPT
Social and Mobile Media in the Librarian Profession
Rowena LI
 
PPT
Week5 ap forms
Rowena LI
 
PPT
Social media as a widget
Rowena LI
 
PPTX
Week7 Dreamweaver Behavior & Image Hotspots
Rowena LI
 
PPT
Week 2
Rowena LI
 
PPT
JavaScript
Rowena LI
 
PPTX
Trabajo de majo
guest21a9f6
 
PDF
Eenadu1
soft srinu
 
PDF
Meet your 2014 Growth Engine: Subscription Revenues
ServiceSource
 
PPTX
Paula
guest21a9f6
 
PDF
Dreamforce 2013 One Hit Wonder Sessions
ServiceSource
 
PDF
Serving the Next-Gen Customer
ServiceSource
 
PDF
Renew OnDemand Brochure
ServiceSource
 
PPT
Keebee/Keeping Kids Busy presentation april 2009
Keeping_Kids_Busy
 
Week 2 HTML lists, hyperlinks, tables, and images
Rowena LI
 
Week1 Dreamweaver and Server
Rowena LI
 
Web 2.0: its impact on library services
Rowena LI
 
Week1 Introduction
Rowena LI
 
Week3 css
Rowena LI
 
Hybrid in 5 minutes
Rowena LI
 
Social and Mobile Media in the Librarian Profession
Rowena LI
 
Week5 ap forms
Rowena LI
 
Social media as a widget
Rowena LI
 
Week7 Dreamweaver Behavior & Image Hotspots
Rowena LI
 
Week 2
Rowena LI
 
JavaScript
Rowena LI
 
Trabajo de majo
guest21a9f6
 
Eenadu1
soft srinu
 
Meet your 2014 Growth Engine: Subscription Revenues
ServiceSource
 
Dreamforce 2013 One Hit Wonder Sessions
ServiceSource
 
Serving the Next-Gen Customer
ServiceSource
 
Renew OnDemand Brochure
ServiceSource
 
Keebee/Keeping Kids Busy presentation april 2009
Keeping_Kids_Busy
 
Ad

Similar to PHP (20)

PDF
Wt unit 4 server side technology-2
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
PPTX
Day1
IRWAA LLC
 
PPT
PHP - Web Development
Niladri Karmakar
 
PPTX
introduction to server-side scripting
Amirul Shafeeq
 
PPTX
Lecture 6: Introduction to PHP and Mysql .pptx
AOmaAli
 
KEY
php app development 1
barryavery
 
PPTX
Php
ayushchugh47
 
PPTX
Lecture 9 - Intruduction to BOOTSTRAP.pptx
AOmaAli
 
PPT
Intro to PHP for Students and professionals
cuyak
 
PPT
php 1
tumetr1
 
PPT
PHP - Introduction to PHP Fundamentals
Vibrant Technologies & Computers
 
PPTX
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
anshkhurana01
 
PPT
Php mysql
Alebachew Zewdu
 
PPT
What Is Php
AVC
 
PPT
introduction to php web programming 2024.ppt
idaaryanie
 
PDF
Programming in PHP Course Material BCA 6th Semester
SanthiNivas
 
PPTX
INTRODUCTION to php.pptx
priyanshupanchal8
 
Wt unit 4 server side technology-2
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
Day1
IRWAA LLC
 
PHP - Web Development
Niladri Karmakar
 
introduction to server-side scripting
Amirul Shafeeq
 
Lecture 6: Introduction to PHP and Mysql .pptx
AOmaAli
 
php app development 1
barryavery
 
Lecture 9 - Intruduction to BOOTSTRAP.pptx
AOmaAli
 
Intro to PHP for Students and professionals
cuyak
 
php 1
tumetr1
 
PHP - Introduction to PHP Fundamentals
Vibrant Technologies & Computers
 
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
anshkhurana01
 
Php mysql
Alebachew Zewdu
 
What Is Php
AVC
 
introduction to php web programming 2024.ppt
idaaryanie
 
Programming in PHP Course Material BCA 6th Semester
SanthiNivas
 
INTRODUCTION to php.pptx
priyanshupanchal8
 
Ad

Recently uploaded (20)

PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PPTX
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
PPTX
QUARTER 1 WEEK 2 PLOT, POV AND CONFLICTS
KynaParas
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PPTX
GRADE-3-PPT-EVE-2025-ENG-Q1-LESSON-1.pptx
EveOdrapngimapNarido
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PPTX
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PPTX
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
PPTX
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PDF
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
QUARTER 1 WEEK 2 PLOT, POV AND CONFLICTS
KynaParas
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
GRADE-3-PPT-EVE-2025-ENG-Q1-LESSON-1.pptx
EveOdrapngimapNarido
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 

PHP

  • 1. PHP an introduction
  • 2. What is PHP? • PHP stands for PHP: Hypertext Preprocessor • PHP is a server-side scripting language, which could be imbedded to HTML • PHP scripts are executed on the server • PHP supports many databases • PHP is an open source software, free to download and use 2
  • 3. PHP Syntax <?php …. ?> <html> <body> <?php echo “Hello World”; ?> </body> </html> 3
  • 4. Text Editors • Dreamweaver Open as php and add code in code view. Use: Insert > php. • Windows Notepad Make sure your files are saved with the .php extension. • Microsoft Word is not optimal for editing PHP files. If you use it, you must save the file as plain text. 4
  • 5. .html or .php: where **Inline** **html code with echo and print* <html> <?php <head> <title>HTML with PHP</title> echo "<html>"; </head> echo "<title>HTML with PHP</title>"; <body> echo "<h1>My example</h1>"; <h1>My Example</h1> //your php code here. <?php //your php code here print "<i>Print works too!</i>"; ?> echo “</html>”; <b>Here is some more html.</b> <?php ?> //your php code here ?> </body> </html> 5
  • 6. .html or .php?? • Open new > Page type: php • Save as .php 6
  • 7. Variables • Variables are used for storing a values, like text strings, numbers or arrays. • When a variable is declared, it can be used over and over again in your script. • All variables in PHP start with a $ sign symbol. • The correct way of declaring a variable in PHP: $name = value; 7
  • 8. Naming Rules for Variables • A variable name must start with a letter or an underscore “_” • A variable name can only contain alpha-numeric characters and underscores (a-z, A-Z, 0-9, and _ ) • A variable name should not contain spaces. If a variable name is more than one word, it should be separated with an underscore ($my_string), or with capitalization ($myString) 8
  • 9. The Concatenation Operator The concatenation operator . is used to put two string together. <?php $txt1=“Hello World!”; $txt2=“What a nice day!”; echo $txt1 . “ ” . $txt2; ?> 9
  • 10. Comments • Comments can be added to explain the PHP. • Single line comments start with //. • Multi line comments start with /* and end with */ 10
  • 11. if…else Syntax <?php if (condition1) {code to be executed if condition1 is true}; elseif (condition2) {code to be executed if condition2 is true}; else {code to be executed if condition1 and condition2 are not true}; ?> 11
  • 12. if…else Example <?php $num1=10; $num2=20; if ($num1>$num2) echo “The first number is greater than the second.<br />”; elseif ($num1<$num2) {echo “The first number is smaller than the second.<br />”; echo “too bad”; } else echo “The first number is equal to the second.<br />”; ?> 12
  • 13. For Loop Syntax The for loop is used when you know in advance how many times the script should run. for (initial condition; end condition; increment) { code to be executed; } 13
  • 14. For Loop Example <?php for ($i=0; $i<=5; $i++) { echo "The number is " . $i; echo “.<br />”; } ?> 14
  • 15. While Loop Syntax Initial variable; while (end variable) { code to be executed; variable increment; } 15
  • 16. While Loop Example <php? $i=0; while ($i<=5) { echo "The number is " . $i . “.<br />”; $i++; } ?> 16
  • 17. Function Syntax • need to be called in order to execute • Can be called multiple times with different variables function funname(var1, var2) { function code; } funname(var1, var2); 17
  • 18. Function Example <?php function getGreeting($user){ return “Hello, $user!”; } echo getGreeting(„Toby‟); ?> 18
  • 19. Function Example function caltax($num1) {$tax=0.0875; $total = $num1+($num1*$tax); echo "The total is $” . $total . ". <br />”; } caltax(100); 19
  • 20. Works Cited Most of the information on this PowerPoint are based on W3Schools Online Web Tutorials PHP section. 20