Learn PHP with MyAssignmenthelp.net (1) - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Learn PHP with MyAssignmenthelp.net (1)

Description:

Best way To Learn PHP is Australia's Best Online Tutoring website Myassignmenthelp.net – PowerPoint PPT presentation

Number of Views:8
Slides: 15
Provided by: myassignmenthelpnet
Tags:

less

Transcript and Presenter's Notes

Title: Learn PHP with MyAssignmenthelp.net (1)


1
  • PHP
  • (Hypertext Preprocessor)

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

www.myassignmenthelp.net
3
PHP Syntax
  • PHP code is executed on the server, and the plain
    HTML result is sent to the browser.
  • Syntax It is starts with lt?php and ends with
    ?gt. A PHP scripting block can be placed anywhere
    in the document.
  • Comments in PHP
  • use // to make a single-line comment or / and /
    to make a large comment block.

lt?php ?gt
lthtmlgtltbodygtlt?php//This is a comment/ This is a comment block / ?gtlt/bodygtlt/htmlgt
Www.myassignmenthelp.net
4
PHP Language Basics
  • Constants, Data Types and Variables
  • Constants define a string or numeric value
  • Constants do not begin with a dollar sign
  • Examples
  • define(COMPANY, Acme Enterprises )
  • define(YELLOW, FFFF00)
  • define(PI, 3.14)
  • define(NL, ltbrgt\n)
  • Data types
  • Integers, doubles and strings
  • isValid true // Boolean
  • 25 // Integer
  • 3.14 // Double
  • Four // String
  • Total value // Another string

5
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 text
  • script assigns the text "Hello" to a string
    variable called text

var_name value
lt?phptextWelcome"echo text?gt
www.myassignmenthelp.net
6
Operators
  • Arithmetic Operators
  • (Addition), - (Subtraction),
    (Multiplication), / (Division), (Modulus
    ), (Increment), -- (Decrement)
  • Assignment Operators
  • , , -, , /, .,
  • Comparison Operators
  • , !, ltgt, gt, lt, gt, lt
  • Logical Operators
  • (and), (or), ! (not)

www.myassignmenthelp.net
7
Conditional Statements
  • if Statement
  • execute some code only if a specified condition
    is true
  • if...else Statement
  • execute some code if a condition is true and
    another code if the condition is false
  • if...elseif....else Statement
  • use this statement to select one of several
    blocks of code to be executed

if (condition) code to be executed if condition is true
if (condition)  code to be executed if condition is trueelse   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
www.myassignmenthelp.net
8
Switch Statement
  • Conditional statements are used to perform
    different actions based on different conditions.
  • Syntax

switch (n)case label1  code to be executed if nlabel1  breakcase label2  code to be executed if nlabel2  breakdefault  code to be executed if n is different from both label1 and label2
www.myassignmenthelp.net
9
Loops
  • while Loop
  • executes a block of code while a condition is
    true.
  • do...while Statement
  • always execute the block of code once, it will
    then check the condition, and repeat the loop
    while the condition is true.

while (condition)    code to be executed 
do    code to be executed  while (condition)
www.myassignmenthelp.net
10
Loops (cont)
  • for Loop
  • The for loop is used when you know in advance how
    many times the script should run.
  • foreach Loop
  • The foreach loop is used to loop through arrays.

for (init condition increment)    code to be executed 
foreach (array as value)    code to be executed 
www.myassignmenthelp.net
11
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

ltform actionresult.php typepostgt ltinput typetext nameemployeegt ltinput typesubmit valueSubmitgt lt/formgt
lt?php employee_name_POST"employee" print employee_name ?gt
www.myassignmenthelp.net
12
_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

ltform actionform.php" method"get"gtName ltinput type"text" name"name" /gtAge ltinput type"text" name"age" /gtltinput type"submit" /gtlt/formgt
http//www.xyz.com/form.php?nameDennyage20
www.myassignmenthelp.net
13
_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.

ltform actionform.php" method"post"gtName ltinput type"text" name"name" /gtAge ltinput type"text" name"age" /gtltinput type"submit" /gtlt/formgt
www.myassignmenthelp.net
14
Thank You
www.myassignmenthelp.net
Write a Comment
User Comments (0)
About PowerShow.com