Internet%20Services - PowerPoint PPT Presentation

About This Presentation
Title:

Internet%20Services

Description:

Variables. Print may also be used. gettype() checks type. settype(var,type) changes type ... typed. Programmer's responsibility to use variables correctly ... – PowerPoint PPT presentation

Number of Views:40
Avg rating:3.0/5.0
Slides: 18
Provided by: chris481
Category:

less

Transcript and Presenter's Notes

Title: Internet%20Services


1
Internet Services
  • PHP
  • Introduction

2
Objectives
  • By the end of this lecture the student should
  • Understand the advantages and disadvantages of
    server-side scripting
  • Understand the basic structure of PHP
  • Understand that it is the programmers
    responsibility to ensure correct HTML and correct
    use of variables

3
PHP Recommended Books
  • Teach Yourself PHP in 24 Hours
  • Matt Zandstra
  • Essential PHP fast
  • Simon Stobart

4
PHP
  • Personal Home Page
  • Server-side scripting
  • Server interprets and sends HTML document to
    browser
  • Available at
  • www.php.net
  • Server from
  • www.omnicron.ca
  • (doesnt need PHP)

5
Server-Side Scripting
  • Advantages
  • Browser independent
  • Run programmes not supported by browser
  • Access data not on browser
  • Security

6
Server-Side Scripting
  • Disadvantages
  • Requires access to server to process input
  • Validation more difficult than with, say,
    JavaScript

7
PHP
  • Embedded within HTML
  • lt?php ?gt tags
  • Similar to C, Perl

8
Example Code
  • lthtmlgt
  • ltheadgt
  • lt/headgt
  • ltbodygt
  • lt?php
  • echo(Hello ltbgtWorld!lt/bgt)
  • ?gt
  • lt/bodygt
  • lt/htmlgt

9
Look at the Source Produced
  • lthtmlgt
  • ltheadgt
  • lt/headgt
  • ltbodygt
  • Hello ltbgtWorld!lt/bgt
  • lt/bodygt
  • lt/htmlgt

10
Example Output
  • Hello World!

11
Programmers Responsibility
  • Programmers responsibility to ensure html is
    correct
  • echo(Hello ltwgtWorldlt/bgt) will produce?
  • Hello World
  • Hello World
  • Hello ltwgtWorldlt/bgt
  • Hello ltwgtWorld

12
PHP
  • Comments
  • // or for single lines
  • / / spans multiple lines

13
Variables
  • PHP supports
  • Integers
  • Floating point (double)
  • Strings
  • Boolean
  • Arrays
  • Objects
  • Start with followed by _ or letter
  • Is not strongly typed

14
Variables
  • May be assigned by
  • Value
  • var1var2
  • var1123
  • Reference
  • var1var2
  • Output with echo statement
  • echo(Value is . var1 . units)
  • . Concatenates a string

15
Variables
  • Print may also be used
  • gettype() checks type
  • settype(var,type) changes type
  • var1( type ) var2 also changes type
  • But
  • var12
  • var2hello
  • var2var2 . var1
  • is OK, as is
  • var2var2var1

16
Variables
  • lt?php
  • var1123
  • echo("var1 was . var1 . "ltbrgt")
  • var112.3
  • echo("var1 is now . var1 . "ltbrgt")
  • var1"Hello Fred"
  • echo("and now it is . var1."ltbrgt")
  • ?gt
  • var1var12 is also allowed here so beware!

17
Summary
  • PHP is server-side scripting
  • Script is interpreted by the server, which sends
    HTML to the browser
  • Programmers responsibility to ensure HTML is
    correct
  • Normal range of types allowed
  • But PHP is not strongly typed
  • Programmers responsibility to use variables
    correctly
Write a Comment
User Comments (0)
About PowerShow.com