SlideShare a Scribd company logo
PHP             (BASIC)




First session
INDEX




•   Into        •   Do … while loop
•   Syntax      •   While loop
•   Variables   •   For loop
•   String      •   Functions
•   Operators   •   Form
•   If else     •   $_POST
•   Switch      •   $_GET
•   Array       •   $_REQUEST
INTRO   • What is PHP?

        • What is MySQL?

        • Why PHP?
PHP SYNTAX   •   Extension
             •   First file name
             •   Where shall we save the project
             •   <?php           ?>



             • <html><body>
             • <?php echo "Hello World"; ?>
             • </body></html>

             • Comments in PHP
VARIABLES   • Creating (Declaring) PHP Variables
            • $myName=“Doksh";
            • PHP has four different variable scopes:

            •   local
            •   global
            •   static
            •   parameter
LOCAL   • <?php
        • $a = 5; // global scope

        •   function myTest()
        •   {
        •   echo $a; // local scope
        •   }

        • myTest();
        • ?>
GLOBAL   • <?php
         • $a = 5;
         • $b = 10;

         •   function myProject()
         •   {
         •   global $a, $b;
         •   $b = $a + $b;
         •   }

         • myProject();
         • echo $b;
         • ?>
STATIC SCOPE   • static $rememberMe;

AND            •   function myTest($a1,$a2,...)
PARAMETERS
               •   {
               •   // function code
               •   }
STRING         •   <?php
VARIABLES IN   •   $txt="Hello World";
PHP            •   echo $txt;
               •   ?>

               • concatenation operator

               • echo $txt1 . " " . $txt2;
STRLEN()   • <?php
FUNCTION   • echo strlen("Hello world!");
&          • ?>
STRPOS()
              ______________________________
FUNCTION

           <?php
           echo strpos("Hello world!","world");
           ?>
OPERATORS   •   +
            •   -
            •   *
            •   /
            •   %
            •   -m
            •   M.m
            •   X=y
            •   X +=y …. etc
            •   ++x per
            •   X++ post
            •   X == y, X != y
            •   X === y, X !== y
            •   X >= y, X >y
            •   X && y
            •   X  y
IF & DATE   •   <html>
            •   <body>

            •   <?php
            •   $d=date("D");
            •   if ($d=="Fri")
            •     {
            •     echo “WOW";
            •     }
            •   elseif ($d=="Sun")
            •     {
            •     echo “OK OK OK OK";
            •     }
            •   else
            •     {
            •     echo “ohhhh!";
            •     }
            •   ?>

            •   </body>
            •   </html>
SWITCH   •   <html>
         •   <body>

         •   <?php
         •   $x=1;
         •   switch ($x)
         •   {
         •   case 1:
         •     echo "Number 1";
         •     break;
         •   case 2:
         •     echo "Number 2";
         •     break;
         •   case 3:
         •     echo "Number 3";
         •     break;
         •   default:
         •     echo "No number ";
         •   }
         •   ?>

         •   </body>
ARRAY   • $Name=array(“Moha",“Tom",“Totti",“
          Nona");

        •   <?php
        •   $Name[0]=“Moha";
        •   $Name[1]=“Tom";
        •   $Name[2]=“Totti";
        •   $Name[3]=“Nona";
        •   echo $Name[0] . " and " . $ Name[1];
        •   ?>
WHILE   • <html>
        • <body>

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

        • </body>
        • </html>
DO WHILE   •   <html>
           •   <body>

           •   <?php
           •   $i=1;
           •   do
           •    {
           •    $i++;
           •    echo "The number is " . $i . "<br />";
           •    }
           •   while ($i<=5);
           •   ?>

           •   </body>
           •   </html
FOR   • <html>
      • <body>

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

      • </body>
      • </html>
FUNCTION   •   <html>
           •   <body>

           •   <?php
           •   function writeName()
           •   {
           •   echo “Mohammed";
           •   }

           •   echo "My name is ";
           •   writeName();
           •   ?>

           •   </body>
           •   </html>
•
FUNCTION   •
               <html>
               <body>

           •   <?php
           •   function writeName($fname,$punctuation)
           •   {
           •   echo $fname . " Refsnes" . $punctuation . "<br />";
           •   }

           •   echo "My name is ";
           •   writeName(“Moha,".");
           •   echo "My sister's name is ";
           •   writeName(“nona","!");
           •   echo "My brother's name is ";
           •   writeName(“amjad","?");
           •   ?>

           •   </body>
           •   </html>
FUNCTION   •   <html>
           •   <body>

           •   <?php
           •   function add($x,$y)
           •   {
           •   $total=$x+$y;
           •   return $total;
           •   }

           •   echo "1 + 16 = " . add(1,16);
           •   ?>

           •   </body>
           •   </html>
FORM   • <html>
       • <body>

       • <form action="welcome.php"
         method="post">
       • Name: <input type="text"
         name="fname" />
       • Age: <input type="text" name="age" />
       • <input type="submit" />
       • </form>

       • </body>
       • </html>
FORM   • <html>
       • <body>
&
POST
       • Welcome <?php echo $_POST["fname"];
         ?>!<br />
       • You are <?php echo $_POST["age"]; ?>
         years old.

       • </body>
       • </html>
GET   • <form action="welcome.php"
        method="get">
      • Name: <input type="text"
        name="fname" />
      • Age: <input type="text" name="age" />
      • <input type="submit" />
      • </form>

      • Welcome <?php echo $_GET["fname"];
        ?>.<br />
      • You are <?php echo $_GET["age"]; ?>
        years old!
REQUEST   • Welcome <?php echo
            $_REQUEST["fname"]; ?>!<br />
          • You are <?php echo $_REQUEST["age"];
            ?> years old.

More Related Content

PPT
PHP Tutorial (funtion)
PDF
Perl6 grammars
TXT
DOC
PDF
PHP 7 – What changed internally?
PDF
穏やかにファイルを削除する
PDF
PHP 7 – What changed internally? (Forum PHP 2015)
PDF
Perl6 in-production
PHP Tutorial (funtion)
Perl6 grammars
PHP 7 – What changed internally?
穏やかにファイルを削除する
PHP 7 – What changed internally? (Forum PHP 2015)
Perl6 in-production

What's hot (20)

PDF
Perl 6 by example
TXT
Wsomdp
PDF
The Perl6 Type System
ODP
Php 102: Out with the Bad, In with the Good
PDF
The Joy of Smartmatch
KEY
(Ab)Using the MetaCPAN API for Fun and Profit
PDF
Leveraging the Power of Graph Databases in PHP
PDF
Leveraging the Power of Graph Databases in PHP
PDF
Top 10 php classic traps
PDF
I, For One, Welcome Our New Perl6 Overlords
PPT
An Elephant of a Different Colour: Hack
KEY
DPC 2012 : PHP in the Dark Workshop
PDF
Introdução ao Perl 6
PDF
Perl Bag of Tricks - Baltimore Perl mongers
PDF
PHP Language Trivia
PDF
Descobrindo a linguagem Perl
PDF
Top 10 php classic traps php serbia
PDF
R57shell
ODP
Perl 6 by example
Wsomdp
The Perl6 Type System
Php 102: Out with the Bad, In with the Good
The Joy of Smartmatch
(Ab)Using the MetaCPAN API for Fun and Profit
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHP
Top 10 php classic traps
I, For One, Welcome Our New Perl6 Overlords
An Elephant of a Different Colour: Hack
DPC 2012 : PHP in the Dark Workshop
Introdução ao Perl 6
Perl Bag of Tricks - Baltimore Perl mongers
PHP Language Trivia
Descobrindo a linguagem Perl
Top 10 php classic traps php serbia
R57shell
Ad

Viewers also liked (6)

PPTX
Php basics
PPTX
Android ui with xml
PPS
Els nous mitjans
PPT
SharePoint 2010 Sandboxed Solution
PDF
A few words about WAMP
PPTX
PHP for HTML Gurus - J and Beyond 2012
Php basics
Android ui with xml
Els nous mitjans
SharePoint 2010 Sandboxed Solution
A few words about WAMP
PHP for HTML Gurus - J and Beyond 2012
Ad

Similar to PHP 1 (20)

PPT
slidesharenew1
PPT
My cool new Slideshow!
PDF
Html , php, mysql intro
PDF
PHP an intro -1
PPT
Php mysql
PDF
Phpbasics
PDF
Winter%200405%20-%20Beginning%20PHP
PDF
Winter%200405%20-%20Beginning%20PHP
PPTX
PPT
PHP and MySQL
PPTX
Quick beginner to Lower-Advanced guide/tutorial in PHP
PPT
PPTX
Day1
PPT
Php basic for vit university
PPT
PHP - Introduction to PHP Fundamentals
PPT
php 1
PPTX
Php basics
PPT
Php(report)
PPT
Prersentation
slidesharenew1
My cool new Slideshow!
Html , php, mysql intro
PHP an intro -1
Php mysql
Phpbasics
Winter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHP
PHP and MySQL
Quick beginner to Lower-Advanced guide/tutorial in PHP
Day1
Php basic for vit university
PHP - Introduction to PHP Fundamentals
php 1
Php basics
Php(report)
Prersentation

Recently uploaded (20)

PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
01-Introduction-to-Information-Management.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Basic Mud Logging Guide for educational purpose
PDF
Classroom Observation Tools for Teachers
PPTX
Institutional Correction lecture only . . .
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Cell Structure & Organelles in detailed.
PDF
Complications of Minimal Access Surgery at WLH
2.FourierTransform-ShortQuestionswithAnswers.pdf
VCE English Exam - Section C Student Revision Booklet
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPH.pptx obstetrics and gynecology in nursing
01-Introduction-to-Information-Management.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Basic Mud Logging Guide for educational purpose
Classroom Observation Tools for Teachers
Institutional Correction lecture only . . .
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Module 4: Burden of Disease Tutorial Slides S2 2025
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Microbial diseases, their pathogenesis and prophylaxis
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Supply Chain Operations Speaking Notes -ICLT Program
O7-L3 Supply Chain Operations - ICLT Program
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
STATICS OF THE RIGID BODIES Hibbelers.pdf
Cell Structure & Organelles in detailed.
Complications of Minimal Access Surgery at WLH

PHP 1

  • 1. PHP (BASIC) First session
  • 2. INDEX • Into • Do … while loop • Syntax • While loop • Variables • For loop • String • Functions • Operators • Form • If else • $_POST • Switch • $_GET • Array • $_REQUEST
  • 3. INTRO • What is PHP? • What is MySQL? • Why PHP?
  • 4. PHP SYNTAX • Extension • First file name • Where shall we save the project • <?php ?> • <html><body> • <?php echo "Hello World"; ?> • </body></html> • Comments in PHP
  • 5. VARIABLES • Creating (Declaring) PHP Variables • $myName=“Doksh"; • PHP has four different variable scopes: • local • global • static • parameter
  • 6. LOCAL • <?php • $a = 5; // global scope • function myTest() • { • echo $a; // local scope • } • myTest(); • ?>
  • 7. GLOBAL • <?php • $a = 5; • $b = 10; • function myProject() • { • global $a, $b; • $b = $a + $b; • } • myProject(); • echo $b; • ?>
  • 8. STATIC SCOPE • static $rememberMe; AND • function myTest($a1,$a2,...) PARAMETERS • { • // function code • }
  • 9. STRING • <?php VARIABLES IN • $txt="Hello World"; PHP • echo $txt; • ?> • concatenation operator • echo $txt1 . " " . $txt2;
  • 10. STRLEN() • <?php FUNCTION • echo strlen("Hello world!"); & • ?> STRPOS() ______________________________ FUNCTION <?php echo strpos("Hello world!","world"); ?>
  • 11. OPERATORS • + • - • * • / • % • -m • M.m • X=y • X +=y …. etc • ++x per • X++ post • X == y, X != y • X === y, X !== y • X >= y, X >y • X && y • X y
  • 12. IF & DATE • <html> • <body> • <?php • $d=date("D"); • if ($d=="Fri") • { • echo “WOW"; • } • elseif ($d=="Sun") • { • echo “OK OK OK OK"; • } • else • { • echo “ohhhh!"; • } • ?> • </body> • </html>
  • 13. SWITCH • <html> • <body> • <?php • $x=1; • switch ($x) • { • case 1: • echo "Number 1"; • break; • case 2: • echo "Number 2"; • break; • case 3: • echo "Number 3"; • break; • default: • echo "No number "; • } • ?> • </body>
  • 14. ARRAY • $Name=array(“Moha",“Tom",“Totti",“ Nona"); • <?php • $Name[0]=“Moha"; • $Name[1]=“Tom"; • $Name[2]=“Totti"; • $Name[3]=“Nona"; • echo $Name[0] . " and " . $ Name[1]; • ?>
  • 15. WHILE • <html> • <body> • <?php • $i=1; • while($i<=5) • { • echo "The number is " . $i . "<br />"; • $i++; • } • ?> • </body> • </html>
  • 16. DO WHILE • <html> • <body> • <?php • $i=1; • do • { • $i++; • echo "The number is " . $i . "<br />"; • } • while ($i<=5); • ?> • </body> • </html
  • 17. FOR • <html> • <body> • <?php • for ($i=1; $i<=5; $i++) • { • echo "The number is " . $i . "<br />"; • } • ?> • </body> • </html>
  • 18. FUNCTION • <html> • <body> • <?php • function writeName() • { • echo “Mohammed"; • } • echo "My name is "; • writeName(); • ?> • </body> • </html>
  • 19. • FUNCTION • <html> <body> • <?php • function writeName($fname,$punctuation) • { • echo $fname . " Refsnes" . $punctuation . "<br />"; • } • echo "My name is "; • writeName(“Moha,"."); • echo "My sister's name is "; • writeName(“nona","!"); • echo "My brother's name is "; • writeName(“amjad","?"); • ?> • </body> • </html>
  • 20. FUNCTION • <html> • <body> • <?php • function add($x,$y) • { • $total=$x+$y; • return $total; • } • echo "1 + 16 = " . add(1,16); • ?> • </body> • </html>
  • 21. FORM • <html> • <body> • <form action="welcome.php" method="post"> • Name: <input type="text" name="fname" /> • Age: <input type="text" name="age" /> • <input type="submit" /> • </form> • </body> • </html>
  • 22. FORM • <html> • <body> & POST • Welcome <?php echo $_POST["fname"]; ?>!<br /> • You are <?php echo $_POST["age"]; ?> years old. • </body> • </html>
  • 23. GET • <form action="welcome.php" method="get"> • Name: <input type="text" name="fname" /> • Age: <input type="text" name="age" /> • <input type="submit" /> • </form> • Welcome <?php echo $_GET["fname"]; ?>.<br /> • You are <?php echo $_GET["age"]; ?> years old!
  • 24. REQUEST • Welcome <?php echo $_REQUEST["fname"]; ?>!<br /> • You are <?php echo $_REQUEST["age"]; ?> years old.