07PHP - CS5281 Internet Application Development Hypertext...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon
CS5281 Internet Application Development Hypertext Preprocessor
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Introduction * We are going to cover the following topics: * What is Hypertext Preprocessor * Basic Syntax * * CS5281 - Hypertext Preprocessor
Background image of page 2
What is Hypertext Preprocessor? * Better known as PHP ( H ypertext P re P rocessor) * A scripting language embedded into HTML templates * Main goal is the generation of dynamic web content * Scripts are executed at the server before being delivered to the client aka CGI programs CS5281 - Hypertext Preprocessor
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
What is Hypertext Preprocessor? (cont.) HTML + PHP HTTP Request <html> <?php print "abc"; Client HTTP Response ?> </html> HTML <html> abc </html> PHP Interpreter Web Server CS5281 - Hypertext Preprocessor
Background image of page 4
Hello World Example <html> <head><title>Hello World</title></head> <body> <?php echo "Hello World!"; ?> </body> </html> <html> <head><title>Hello World</title></head> <body> Hello World! </body> </html> CS5281 - Hypertext Preprocessor
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
PHP Scripts * Can do whatever a CGI program can do * Cross platform and open source * Support almost any databases * PHP scripts are inserted into HTML template by a pair of tags * <?php « php code goes here « ?> CS5281 - Hypertext Preprocessor
Background image of page 6
Download PHP * The latest version of PHP can be download from this location: * http://www.php.net/downloads.php * Your CS Lab account supports PHP already. CS5281 - Hypertext Preprocessor
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Basic Syntax * PHP insertion can be accomplished by different types of tags * <?php php_code ?> * The default type of tags * <? php_code ?> * Short form and is turned off by default * <?= php_expression ?> * i.e. <? echo php_expression ?> CS5281 - Hypertext Preprocessor
Background image of page 8
Statements and Comments * Statements are ended with semi-colon * php_statement ; php_statement ; * Comments can be written in the following ways * // This is a one line comment * /* This can be multiple lines comment */ * # This is also a one line comment CS5281 - Hypertext Preprocessor
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Data Types Data Type boolean integer float string array object Example $bool = true; $bool = false; $a = 1234; $a = -50; $a = 0xFF; $b = 1.35; $b = 5E10; $s = 'I am a string!'; $s = "I am also a string!"; $s = "I am a string with variables $a and $b!"; $arr[1] = "one dimensional array"; $arr[2][0] = "two dimensional array"; $me = new object; $c = $me->attribute; $me->method(); CS5281 - Hypertext Preprocessor
Background image of page 10
* PHP is a language with implicit typing * A variable is declared in its first assignment * $ var = " Hello " ; declares a variable with an initial value * You can explicitly change a data type by the settype() function, or, even better, use type-casting. CS5281 - Hypertext Preprocessor
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/11/2011 for the course CS 5281 taught by Professor Jianyingwang during the Summer '10 term at City University of Hong Kong.

Page1 / 34

07PHP - CS5281 Internet Application Development Hypertext...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online