Design of Multiplayer Games COSC 418 PHP Syntax - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

Design of Multiplayer Games COSC 418 PHP Syntax

Description:

You cannot view the PHP source code by selecting 'View source' in the browser ... grep r.t text.txt. Forms form name='nim' action='nimparser.php' method='post' ... – PowerPoint PPT presentation

Number of Views:46
Avg rating:3.0/5.0
Slides: 17
Provided by: kathleenha
Category:

less

Transcript and Presenter's Notes

Title: Design of Multiplayer Games COSC 418 PHP Syntax


1
Design of Multiplayer GamesCOSC 418PHP Syntax
  • From www.w3schools.com

2
PHP Creates HTML Pages
  • You cannot view the PHP source code by selecting
    "View source" in the browser - you will only see
    the output from the PHP file, which is plain
    HTML.
  • This is because the scripts are executed on the
    server before the result is sent back to the
    browser.

Client HTTP Request
Server HTTP Daemon
PHP Hypertext Preprocessor
3
Basic PHP Syntax
  • A PHP file normally contains HTML tags, just like
    an HTML file, and some PHP scripting code.
  • Below, we have an example of a simple PHP script
    which sends the text "Hello World" to the
    browserlthtmlgt ltbodygt lt?php echo "Hello
    World" ?gt lt/bodygt lt/htmlgt
  • A PHP scripting block always starts with lt?php
    and ends with ?gt.

4
Basic PHP Syntax
  • A PHP scripting block can be placed anywhere in
    the document.
  • Each code line in PHP must end with a semicolon.
    The semicolon is a separator and is used to
    distinguish one set of instructions from another.

5
PHP Output
  • There are two basic statements to output text
    with PHP
  • echo
  • print
  • In the example on the earlier slide we used the
    echo statement to output the text "Hello World".

6
Variables in PHP
  • All variables in PHP start with a sign symbol.
  • Variables may contain strings, numbers, or
    arrays.
  • Below, the PHP script assigns the string "Hello
    World" to a variable called txtlthtmlgt ltbodygt
    lt?php txt"Hello World" echo txt ?gt
    lt/bodygt lt/htmlgt

7
The Dot . Operator
  • To concatenate two or more variables together,
    use the dot (.) operatorlthtmlgt ltbodygt
    lt?php txt1"Hello World"
    txt2"1234" echo txt1 . " " .
    txt2 ?gt lt/bodygt lt/htmlgt
  • The output of the script above will be "Hello
    World 1234".

8
Comments in PHP
  • In PHP, we use // to make a single-line comment
    or / and / to make a large comment
    block.lthtmlgt ltbodygt lt?php //This is a
    comment / This is a
    comment block / ?gt lt/bodygtlt/htmlgt

9
PHP Operators
  • Arithmetic Operators

10
PHP Operators
  • Assignment Operators

11
PHP Operators
  • Comparison Operators

12
PHP Operators
  • Logical Operators

13
PHP Data Types
  • Integer
  • Double
  • String
  • Able to reassign type within an expression.
  • P. 57
  • somevar 1
  • somevar 2.67
  • somevar 123A String
  • x 5 somevar x now equals 128

14
Regular Expressions
  • A regular expression is a formula for matching
    strings that follow a pattern.
  • Used as arguments for many functions.
  • grep r.t text.txt

15
Forms
16
  • ltform namenim actionnimparser.php
    methodpostgt
  • In the file nimparser.php, it calls it self with
    the form data supplied on the return.
  • The form data is available via the _REQUEST
    system array.
Write a Comment
User Comments (0)
About PowerShow.com