COSC 416 week seven - PowerPoint PPT Presentation

1 / 56
About This Presentation
Title:

COSC 416 week seven

Description:

GET /index.php. Client. Server. HTTP server. PHP. HTTP request. Should the. requested file ... The white screen of death. Check your semicolons ?php. echo ' ... – PowerPoint PPT presentation

Number of Views:26
Avg rating:3.0/5.0
Slides: 57
Provided by: randy99
Category:
Tags: cosc | death | index | seven | week

less

Transcript and Presenter's Notes

Title: COSC 416 week seven


1
COSC 416week seven http//iat.ubalt.edu/courses/
cosc416.101_sp08/
2
Programming
3
Math
  • x 2 4
  • x ?

4
Math
  • x 2 4
  • x 2

5
Variables
  • a number 2 4

6
Variables
  • a_number 2 4

7
Variables
  • a_number 2 another_number

8
Variables
  • parameter 2 return_value
  • 2 2 ?

9
Variables
  • parameter 2 return_value
  • 2 2 4

10
Math
  • f(x) x 2
  • f(2) ?
  • f(4) ?

11
Math
  • f(x) x 2
  • f(2) 4
  • f(4) 6

12
Functions
  • f(parameter) return_value

13
Functions
  • f(x, y) x y
  • f(10, 10) ?
  • f(1, 100) ?

14
Functions
  • f(x, y) x y
  • f(10, 10) 20
  • f(1, 100) 101

15
Functions
  • f(x, y) x y
  • f(10, f(10, 10)) ?

16
Functions
  • f(x, y) x y
  • f(10, f(10, 10)) 30

17
Functions
  • f(x, y) x y
  • f(10, f(10, 10)) 30
  • f(10, 20) 30

18
Functions
  • f(x, y) x y
  • z f(10, 10)
  • f(10, z) 30

19
Functions
  • f(x, y) x y
  • f(x) x 2

20
Functions
  • sum(x, y) x y
  • add_two_to(x) x 2
  • sum(10, 20) ?
  • add_two_to(6) ?

21
Functions
  • sum(x, y) x y
  • add_two_to(x) x 2
  • sum(10, 20) 30
  • add_two_to(6) 8

22
Functions
  • sum(x, y) x y
  • add_two_to(x) x 2
  • z sum(10, 10)
  • add_two_to(z) 22

23
Functions
  • sum(x, y) x y
  • add_two_to(x)
  • sum(x, 2)

24
PHP Functions
  • function sum(x, y)
  • return x y
  • function add_two_to(x)
  • return sum(x, 2)
  • z 20
  • add_two_to(z)

25
PHP Functions
  • function name(parameters)
  • // manipulate parameters
  • return return_value

26
PHP Functions
  • function k(parameter)
  • return parameter
  • initial 2
  • new_value k(initial)

27
PHP
28
Webclient
www.example.comWeb server
HTTP server
HTTP client
80
index.html
29
Webclient
www.example.comWeb server
HTTP server
HTTP client
80
index.html
PHPinterpreter
30
Webclient
www.example.comWeb server
Should PHP be used to process this request?
HTTP server
HTTP client
80
index.html
PHPinterpreter
31
Webclient
www.example.comWeb server
No
GET /index.html
HTTP server
HTTP client
80
index.html
PHPinterpreter
32
Webclient
www.example.comWeb server
Yes
GET /index.php
HTTP server
HTTP client
80
index.php
PHPinterpreter
33
Client
Server
HTTP server
PHP
Should therequested filebe processedby PHP?
HTTP request
34
Client
Server
HTTP server
PHP
Should therequested filebe processedby PHP?
HTTP request
No
Add HTML from the file to an HTTPresponse
HTTP response
35
.php file extension turns on the PHP
interpreter(on our server)
36
Client
Server
HTTP server
PHP
Should thefile requestedbe processedby PHP?
HTTP request
Execute any PHP code in the file
Yes
Send interpreted file to HTTP server
Add PHP output as HTML to an HTTPresponse
HTTP response
37
.php file extension turns on the PHP
interpreter(on our server)
38
HTTP server
PHP
hello.php
...ltpgtlt?php echo "hello"?gtlt/pgt...
GET hello.php
...ltpgthellolt/pgt...
HTTP response
39
PHP code
Open and close tags
lt?php?gt
40
PHP code
Statements
lt?php echo "Hi"?gt
41
PHP code
Semicolons!
lt?php echo "Hi"?gt
42
PHP code
Comments
lt?php outputs Hi echo "Hi"?gt
43
PHP code
Types Numbers
lt?php integer 1 float 1.1?gt
44
PHP code
Types Strings
lt?php string "Hi" string 'Hi'?gt
45
PHP code
Escaping in strings
lt?php msg "Say \"Hi\""?gt
46
PHP code
Combining strings
lt?php s "Hi"." there" s "Hi there"?gt
47
PHP code
Types Arrays
lt?php array array() array 'Hi'
array0 Hi?gt
48
(No Transcript)
49
The white screen of death
Check your semicolonslt?php echo "Hello"?gt
50
The white screen of death
Check your semicolonslt?php echo "Hello"?gt
51
The white screen of death
Check your quoteslt?php echo "Hello?gt
52
The white screen of death
Check your quoteslt?php echo "Hello"?gt
53
The white screen of death
Check your parentheseslt?php echo("Hello"?gt
54
The white screen of death
Check your parentheseslt?php echo("Hello")?gt
55
The white screen of death
Check your curly braceslt?php if (a b)
echo "True!"?gt
56
The white screen of death
Check your curly braceslt?php if (a b)
echo "True!" ?gt
Write a Comment
User Comments (0)
About PowerShow.com