150 likes | 304 Views
PHP Overview. for educators and instructional designers By Martin Yeh 06/28/2007. What is PHP?. PHP: Hypertext Preprocessor It is a server-side scripting language. JavaScript (client-side) ASP, JSP (server-side) It is free to download. Often works with Apache and MySQL.
E N D
PHP Overview for educators and instructional designers By Martin Yeh 06/28/2007
What is PHP? • PHP: Hypertext Preprocessor • It is a server-side scripting language. • JavaScript (client-side) • ASP, JSP (server-side) • It is free to download. • Often works with Apache and MySQL. Penn State University Martin Yeh
How Popular is PHP • Top 5 most popular programming language: Java, C, C++, (Visual) Basic, PHP (http://www.tiobe.com/tpci.htm) Penn State University Martin Yeh
Background Knowledge • HTML • Apache: web server • MySQL: database systems • Server-Client: a concept about the relationship of networked computers. Penn State University Martin Yeh
HTTP Request HTTP Request HTTP Response HTTP Response Web Browser (Client) Apache (Server) PHP module How PHP work? • From users’ perspective, this process is transparent Web Browser (Client) Apache (Server) Penn State University Martin Yeh
PHP Scripts • File name extension • depends on server settings. • usually by the extension of .php .php3 .phtml • Inside the script: <?php your php script goes here ?> Penn State University Martin Yeh
First PHP Script • Under Dreamweaver, select File->New, select “Basic page”, “HTML”, and make sure that “Make document XHTML compliant” • Move cursor to the end of <body> • Press “Enter” • Add these three lines: <?php echo “Hello World”; ?> Penn State University Martin Yeh
Completed First Script <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <?php echo “Hello World”; ?> </body> </html> Penn State University Martin Yeh
Let’s See The HTML Source • Save the file, upload it to PSU web space. • Browse this file using any web browser. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> Hello World</body> </html> Penn State University Martin Yeh
What Does PHP Module Do • Executes the scripts embedded inside <?php and ?> • In the first script echo “Hello World”;is executed and the result is simply hello world Penn State University Martin Yeh
Another PHP Script • Type the following code in your favorite text editor and save it to server_info.php. <?php phpinfo(); ?> • Upload it to your PUS personal web space. • Open a browser and point it to http://www.personal.psu.edu/your_psu_id/server_info.php Penn State University Martin Yeh
Penn State University Martin Yeh
Programming & PHP • Input • Getting data from standard input device, files, database systems • PHP: HTML form, read files, connecting to database systems • Process • Your program logics • Output • Standard output device • Files • Database systems Penn State University Martin Yeh
Some PHP Sites • http://wise.berkeley.com • http://www.limesurvey.org • http://wikindx.sourceforge.net • http://www.personal.psu.edu/kqy1/cbr Penn State University Martin Yeh
Dive into PHP • Last updated • Email form Penn State University Martin Yeh