PHP Lecture 3

Embed Size (px)

Citation preview

  • 8/12/2019 PHP Lecture 3

    1/22

    What is PHP?

    PHP stands for PHP: Hypertext Preprocessor

    PHP is a server-side scripting language, like ASP

    PHP scripts are executed on the server

    PHP supports many databases (MySQL, Informix,

    Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.)

  • 8/12/2019 PHP Lecture 3

    2/22

    What is a PHP File?

    PHP files can contain text, HTML tags and scripts

    PHP files are returned to the browser as plain HTMLPHP files have a file extension of ".php",

  • 8/12/2019 PHP Lecture 3

    3/22

    What is MySQL?

    MySQL is a database server

    MySQL is ideal for both small and large applications

    MySQL supports standard SQLMySQL compiles on a number of platforms

    MySQL is free to download and use

  • 8/12/2019 PHP Lecture 3

    4/22

  • 8/12/2019 PHP Lecture 3

    5/22

    Where to Start?

    To get access to a web server with PHP support, you can:

    Install Apache (or IIS) on your own server, install PHP, and MySQL

    Or find a web hosting plan with PHP and MySQL support

  • 8/12/2019 PHP Lecture 3

    6/22

  • 8/12/2019 PHP Lecture 3

    7/22

  • 8/12/2019 PHP Lecture 3

    8/22

  • 8/12/2019 PHP Lecture 3

    9/22

  • 8/12/2019 PHP Lecture 3

    10/22

    $addition = 2 + 4;

    $subtraction = 6 - 2;

    $multiplication = 5 * 3;

    $division = 15 / 3;

    $modulus = 5 % 2;

    echo "Perform addition: 2 + 4 = ".$addition."
    ";

    echo "Perform subtraction: 6 - 2 = ".$subtraction."
    "; echo

    "Perform multiplication: 5 * 3 = ".$multiplication."
    ";

    echo "Perform division: 15 / 3 = ".$division."
    ";

    echo "Perform modulus: 5 % 2 = " . $modulus . ". Modulus is the

    remainder after the division operation has been performed. In this

    case it was 5 / 2, which has a remainder of 1.";

  • 8/12/2019 PHP Lecture 3

    11/22

  • 8/12/2019 PHP Lecture 3

    12/22

    $my_name = "someguy";if ( $my_name == "someguy" )

    {

    echo "Your name is someguy!
    ";}

    echo "Welcome to my homepage!";

  • 8/12/2019 PHP Lecture 3

    13/22

    $my_name = anotherguy";if ( $my_name == "someguy" )

    {

    echo "Your name is someguy!
    ";}

    echo "Welcome to my homepage!";

  • 8/12/2019 PHP Lecture 3

    14/22

    $number_three = 3;

    if ( $number_three == 3 )

    { echo "The if statement evaluated to true";

    }else

    {

    echo "The if statement evaluated to false";}

  • 8/12/2019 PHP Lecture 3

    15/22

    $employee = "Bob";

    if($employee == "Ms. Tanner"){

    echo "Hello Ma'am";

    } elseif($employee == "Bob"){echo "Good Morning Sir!";

    } else {

    echo "Morning";}

  • 8/12/2019 PHP Lecture 3

    16/22

    $destination = "Tokyo";

    echo "Traveling to $destination
    ";

    switch ($destination){

    case "Las Vegas":echo "Bring an extra $500";

    break;

    case "Amsterdam":

    echo "Bring an open mind";

    break;case "Egypt":

    echo "Bring 15 bottles of PEPSI";

    break;

    case "Tokyo":

    echo "Bring lots of money";

    break;

    case "Caribbean Islands":

    echo "Bring a swimsuit";

    break;

    }

  • 8/12/2019 PHP Lecture 3

    17/22

    $destination = "Tokyo";

    echo "Traveling to $destination
    ";

    switch ($destination){

    case "Las Vegas":

    echo "Bring an extra $500";

    break;

    case "Amsterdam":

    echo "Bring an open mind";

    break;

    case "Egypt":

    echo "Bring 15 bottles of PEPSI";break;

    case "Tokyo":

    echo "Bring lots of money";

    break;

    case "Caribbean Islands":echo "Bring a swimsuit";

    break;

    default:

    echo LEAVE IT!";

    break;}

  • 8/12/2019 PHP Lecture 3

    18/22

    Art Supply Order Form

    Paint

    Brushes

    Erasers

    Quantity:

  • 8/12/2019 PHP Lecture 3

    19/22

  • 8/12/2019 PHP Lecture 3

    20/22

  • 8/12/2019 PHP Lecture 3

    21/22

  • 8/12/2019 PHP Lecture 3

    22/22