Title: PHP
1PHP
2PHP HypertextPreprocessor
3Client
Server
HTTP server
PHP
Should therequested filebe processedby PHP?
HTTP request
4Client
Server
HTTP server
PHP
Should therequested filebe processedby PHP?
HTTP request
No
Add HTML from the file to an HTTPresponse
HTTP response
5.php file extension turns on PHP interpreter(on
our server)
6Client
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
7.php file extension turns on PHP interpreter(on
our server)
8HTTP server
PHP
hello.php
...ltpgtlt?php echo "hello"?gtlt/pgt...
GET hello.php
...ltpgthellolt/pgt...
HTTP response
9PHP code
Open and close tags
lt?php?gt
10PHP code
Statements
lt?php echo "Hi"?gt
11PHP code
Semicolons!
lt?php echo "Hi"?gt
12PHP code
Comments
lt?php outputs Hi echo "Hi"?gt
13PHP code
Types Numbers
lt?php integer 1 float 1.1?gt
14PHP code
Types Strings
lt?php string "Hi" string 'Hi'?gt
15PHP code
Escaping in strings
lt?php msg "Say \"Hi\""?gt
16PHP code
Combining strings
lt?php s "Hi"." there" s "Hi there"?gt
17PHP code
Types Arrays
lt?php array array() array 'Hi'
array0 Hi?gt
18(No Transcript)
19The white screen of death
Check your semicolonslt?php echo "Hello"?gt
20The white screen of death
Check your semicolonslt?php echo "Hello"?gt
Check your quoteslt?php echo "Hello?gt
21The white screen of death
Check your parentheseslt?php echo("Hello"?gt
Check your curly braceslt?php if (a b)
echo "True!"?gt