Internet Software Architectures - PowerPoint PPT Presentation

About This Presentation
Title:

Internet Software Architectures

Description:

By the end of this lecture the student should: Understand how ... { case result1: some statements. break; case result2: some other statements. break; default: ... – PowerPoint PPT presentation

Number of Views:11
Avg rating:3.0/5.0
Slides: 16
Provided by: chris481
Category:

less

Transcript and Presenter's Notes

Title: Internet Software Architectures


1
Internet Software Architectures
  • Lecture Two
  • Operators and Flow Control

2
Objectives
  • By the end of this lecture the student should
  • Understand how comparison operators work in PHP
  • Understand how to control the flow of a PHP
    script
  • Be able to apply the various PHP operators

3
Environment Variables
  • phpinfo() produces web page
  • With environment and php variables displayed
  • Accessible within php by name
  • Eg REMOTE_ADDR returns IP address of client

4
(No Transcript)
5
Comparison Operators
  • ! ! lt gt gt lt allowed
  • is
  • Equal to
  • Not equal to
  • Really really equal to
  • Identical to
  • Identical the same in type and value

6
Flow Control
  • Supports
  • if elseif else
  • while
  • do while
  • switch
  • for

7
If
  • if (expression) some statements
  • if (expression) some statements
  • else some more statements
  • if (expression) some statements
  • elseif (expression) some more statements
  • else some more statements

8
If
  • if (var lt 0)
  • echo(The variable has the negative value .
    var . ltpgt)
  • elseif (var 0)
  • echo(The variable has the value of zeroltpgt)
  • else
  • echo(The variable has the positive value .
    var . ltpgt)

9
For loop
  • for (expression1 expression2 expression3)
    statement
  • Expression 1 is the start condition
  • Expression 2 is the end condition
  • Expression 3 is the increment operation
  • for (c1 clt10 c)
  • echo (c . ltbrgt)

10
For loop
  • for (c1 clt10 c)
  • echo (c . ltbrgt)
  • echo (c2 . ltbrgt)
  • endfor
  • Braces may also be used
  • Use this in tutorial to create 12 times table
    page (with appropriate headers etc)

11
While
  • while (expression) some statements
  • x1
  • while (xlt10)
  • echo(x . ltbrgt)
  • x

12
Do While
  • do
  • something
  • while (expression)

13
Switch
  • switch (expression)
  • case result1
  • some statements
  • break
  • case result2
  • some other statements
  • break
  • default
  • something else

14
Operators
  • - / -- operators allowed
  • ? ternary operator
  • (expression) ? if_true if_false
  • mood sad
  • text ( moodhappy ) ? Hooray Leave me
    alone
  • echo (ltbrgt . text)

15
Summary
  • PHP gives access to a lot of system information
  • Operators in PHP are very similar to C
  • - / -- ?
  • comparison gt lt gt lt
  • Flow Control in PHP is also very similar to C
  • if, for, while, do while, switch
Write a Comment
User Comments (0)
About PowerShow.com