learn php with myassignmenthelp.net

14
PHP (Hypertext Preprocessor) www.myassignmenthelp.

Upload: stevejohnson

Post on 12-Nov-2015

6 views

Category:

Documents


2 download

DESCRIPTION

Myassignmenthelp.net Presents a new and intuitive way of learning PHP.

TRANSCRIPT

  • PHP (Hypertext Preprocessor) www.myassignmenthelp.net

  • Overview of PHPPHP stands for Hypertext PreprocessorCreated by Rasmus Lerdorf in 1995It is an open source softwareIt is server-side scripting language, like ASP and executed on the serverMore functionality added (OOP features), database support, protocols and APIsA language that combines elements of Perl, C, and JavaIt is free to use and download PHP files can contain text, HTML tags and scripts and file extension of ".php" or ".phtmlPHP files are returned to the browser as plain HTML www.myassignmenthelp.net

  • PHP Syntax

    PHP code is executed on the server, and the plain HTML result is sent to the browser.Syntax: It is starts with . A PHP scripting block can be placed anywhere in the document.

    Comments in PHPuse // to make a single-line comment or /* and */ to make a large comment block.

    Www.myassignmenthelp.net

  • PHP Language BasicsConstants, Data Types and VariablesConstants define a string or numeric valueConstants do not begin with a dollar signExamples:define(COMPANY, Acme Enterprises );define(YELLOW, #FFFF00);define(PI, 3.14);define(NL, \n);

    Data typesIntegers, doubles and stringsisValid = true; // Boolean25 // Integer3.14 // DoubleFour // StringTotal value // Another string

  • Variables

    It is used to store information.It is used for storing information, like text strings, numbers or arrays.All variables in PHP start with a $ sign symbol.The declaring a variable

    String variable: used to store and manipulate textscript assigns the text "Hello" to a string variable called $text:

    www.myassignmenthelp.net

    $var_name = value;

  • Operators

    Arithmetic Operators+ (Addition), - (Subtraction), * (Multiplication), / (Division), % (Modulus ), ++ (Increment), -- (Decrement)

    Assignment Operators=, +=, -=, *=, /=, .=, %=

    Comparison Operators==, !=, , >, =,

  • Conditional Statements

    if Statementexecute some code only if a specified condition is true

    if...else Statementexecute some code if a condition is true and another code if the condition is false

    if...elseif....else Statementuse this statement to select one of several blocks of code to be executed

    www.myassignmenthelp.net

    if (condition) code to be executed if condition is true;

    if (condition) code to be executed if condition is true; else code to be executed if condition is false;

    if (condition) code to be executed if condition is true; elseif (condition) code to be executed if condition is true; else code to be executed if condition is false;

  • Switch Statement

    Conditional statements are used to perform different actions based on different conditions.Syntax:

    www.myassignmenthelp.net

    switch (n) { case label1: code to be executed if n=label1; break; case label2: code to be executed if n=label2; break; default: code to be executed if n is different from both label1 and label2; }

  • Loops

    while Loopexecutes a block of code while a condition is true.

    do...while Statementalways execute the block of code once, it will then check the condition, and repeat the loop while the condition is true.

    www.myassignmenthelp.net

    while (condition) { code to be executed; }

    do { code to be executed; } while (condition);

  • Loops (cont)

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

    foreach LoopThe foreach loop is used to loop through arrays.

    www.myassignmenthelp.net

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

    foreach ($array as $value) { code to be executed; }

  • Form

    One of the main features in PHP is the ability to take user input and generate subsequent pages on the input. In this page, we will introduce the mechanism by which data is passes in PHP.Let's consider the following two files:query.php

    result.php

    www.myassignmenthelp.net

  • $_GET Function

    The built-in $_GET function is used to collect values in a form with method="get".When using method="get" in HTML forms, all variable names and values are displayed in the URL.Information sent from a form with the GET method is visible to everyone and has limits on the amount of information to send.

    When the user clicks the "Submit" button, the URL sent to the server could look something like this:

    www.myassignmenthelp.net

  • $_POST Function

    The built-in $_POST function is used to collect values from a form sent with method="post".Information sent from a form with the POST method is invisible to others and has no limits on the amount of information to send and the variables are not displayed in the URL and 8 Mb max size for the POST method, by default also can be changed by setting the post_max_size in the php.ini file.Information sent from a form with the POST method is invisible to others and has no limits on the amount of information to send.

    www.myassignmenthelp.net

  • www.myassignmenthelp.net

    Thank You

    **************