PHP Programming: PHP Crush Course! Learn PHP Programming ...
PHP Overview
-
Upload
mason-cook -
Category
Documents
-
view
18 -
download
0
description
Transcript of PHP Overview
PHP Overview
for educators and instructional designersBy
Martin Yeh06/28/2007
Penn State UniversityMartin Yeh
06/28/20072 / 15
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 UniversityMartin Yeh
06/28/20073 / 15
How Popular is PHP
• Top 5 most popular programming language: Java, C, C++, (Visual) Basic, PHP (http://www.tiobe.com/tpci.htm)
Penn State UniversityMartin Yeh
06/28/20074 / 15
Background Knowledge
• HTML
• Apache: web server
• MySQL: database systems
• Server-Client: a concept about the relationship of networked computers.
Penn State UniversityMartin Yeh
06/28/20075 / 15
How PHP work?
Web Browser(Client)
Apache
(Server)
HTTP Request
HTTP Response
HTTP Request
HTTP Response
Web Browser(Client)
Apache
(Server)
PHP module
• From users’ perspective, this process is transparent
Penn State UniversityMartin Yeh
06/28/20076 / 15
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 UniversityMartin Yeh
06/28/20077 / 15
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 UniversityMartin Yeh
06/28/20078 / 15
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 UniversityMartin Yeh
06/28/20079 / 15
Let’s See The HTML Source
<!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>
• Save the file, upload it to PSU web space.
• Browse this file using any web browser.
Penn State UniversityMartin Yeh
06/28/200710 / 15
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 UniversityMartin Yeh
06/28/200711 / 15
Another PHP Script
<?phpphpinfo();?>
• Type the following code in your favorite text editor and save it to server_info.php.
• 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 UniversityMartin Yeh
06/28/200712 / 15
Penn State UniversityMartin Yeh
06/28/200713 / 15
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 UniversityMartin Yeh
06/28/200714 / 15
Some PHP Sites
• http://wise.berkeley.com
• http://www.limesurvey.org
• http://wikindx.sourceforge.net
• http://www.personal.psu.edu/kqy1/cbr
Penn State UniversityMartin Yeh
06/28/200715 / 15
Dive into PHP
• Last updated
• Email form