CSE134A LECTURE NOTES

September 30, 2002
 
 

WELCOME

This is CSE 134A.  Please see today's introductory handout.  Points to note: Class will start at 5pm sharp and end at 6:20pm sharp.
 
 

OVERVIEW OF THE COURSE

We will study modern software that is in widespread use: the PHP scripting language (version 4) and the MySQL relational database client/server software.

CSE 134A teaches how to develop web-based applications that deliver information dynamically, either to human users or ("web services") to other applications.

The course will cover architectures for server-side web-based systems that scale to thousands and even millions of users.  The topics discussed will be related to Windows DNA, Microsoft .NET, and Sun ONE, but will not be vendor-specific.  Standards for information exchange over the Internet including XML and SOAP will be covered.

The course may also cover algorithms for organizing and searching web-based information, such as those used by the Google search engine.

Topics that will be mentioned in 134A but not covered systematically include IP networking, relational database systems in general, web server design, HTML, user interface design, and text processing using regular expressions.

We chose PHP and MySQL because they are open-source and free.  You are encouraged to install your own copies of the software on your own Linux machine.
 
 

PHP IS A SCRIPTING LANGUAGE

The first web servers, around 1995, provided only static web pages, written in HTML.

A PHP-based web page looks like HTML interleaved with programming commands in a language that resembles C and Perl.  Other software technologies that are similar include Microsoft ASP, Cold Fusion, Java, Java Server Pages, and Java servlets.

One main advantages of PHP version 4 is Zend, a byte-code compiler that is invoked automatically.  This makes PHP pages run much faster, and is similar to how Java is implemented.

A PHP program (called a script) is executed on the web server computer, unlike Javascript, which is executed by the client browser.

PHP commands have access to information about the browser, the values of fields in a form on the browser, and can retrieve and/or update information in a database.

General applications: Responding to forms, displaying user-customized content, rotating content.  Examples: Slashdot, bug tracking, shopping cart.
 
 

HOW PHP WORKS

The web server, for example Apache under Linux, proceeds as follows: A PHP program (called a script) is executed on the web server computer, unlike Javascript, which is executed by the client browser.

PHP commands have access to information about the browser, the values of fields in a form on the browser, and can retrieve and/or update information in a database.
 
 

WRITING A PHP PAGE

Here's an example of an HTML page that includes PHP code:

      <HTML>
       <?php
              print("<P>\nHello world from <EM>PHP</EM>.");
       ?>
   </HTML>

The PHP code is inside <? ?> script tags, which are nested inside HTML.  HTML stands for Hypertext Markup Language.  <P> is a markup command nested inside the PHP string. \n is an escape character for "new line."

You create this page as an ascii file using a text editor, then save it in your web directory with the name test.php for example.  PHP has very forgiving syntax.  print and echo are synonyms, and the parentheses are optional.

If you load test.php in your browser and do "view source" you see this:

       <HTML>
       <P>
       Hello world from <EM>PHP</EM>.</HTML>

Notice where the new lines are and are not.

Variable names in PHP start with the dollar symbol.  As in most scripting languages, e.g. awk and Perl, typing is dynamic.
 
 



Copyright (c) by Charles Elkan, 2002.