PHP Overview

15
PHP Overview for educators and instructional designers By Martin Yeh 06/28/2007

description

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. - PowerPoint PPT Presentation

Transcript of PHP Overview

Page 1: PHP Overview

PHP Overview

for educators and instructional designersBy

Martin Yeh06/28/2007

Page 2: PHP Overview

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.

Page 3: PHP Overview

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)

Page 4: PHP Overview

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.

Page 5: PHP Overview

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

Page 6: PHP Overview

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

?>

Page 7: PHP Overview

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”;?>

Page 8: PHP Overview

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>

Page 9: PHP Overview

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.

Page 10: PHP Overview

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

Page 11: PHP Overview

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

Page 12: PHP Overview

Penn State UniversityMartin Yeh

06/28/200712 / 15

Page 13: PHP Overview

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

Page 14: PHP Overview

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

Page 15: PHP Overview

Penn State UniversityMartin Yeh

06/28/200715 / 15

Dive into PHP

• Last updated

• Email form