Please send questions to st10@humboldt.edu .

CIS 180 php - Intro to PHP - Session 1 - 10-31-06 - projected notes

*   PHP - recursive acronym

    *   PHP - Hypertext Processor

    *   an HTML-embedded scripting language

        *   you type the PHP code within HTML (like JavaScript, JSP)

    *   much of its syntax is borrowed from C, Java, Perl

    *   THE source on-line for PHP: www.php.net

    *   PHP's primary purpose: to write dynamically generated web
        pages quickly

    *   some of its strengths:
        *   it's free
        *   it's cross-platform
        *   it is widely used
        *   it hides its complexity (we'll see about that...)
        *   it is built for web programming
        *   it works and plays well with databases

*   so - this is embedded in HTML - how do you indicate that it's PHP?

    *   with a tag -- and the PREFERRED tag:

        <?php
            // php goes here
        ?>

    *   and by NAMING the file so its ends with the suffix .php

*   PHP is SERVER-SIDE (as opposed to, say, client-side)

    *   client asks for a page ---

    *   the server notices it has a suffix .php
  
    *   it invokes the PHP preprocessor, which executes the PHP
        within and outputs the resulting (dynamic) page,

    *   and that RESULTING page is sent to the browser/client
        for display

*   now for the dreaded "hello world" example (hello.php)

    *   type it in in plain text...

    *   end the file name with the suffix .php

    *   and make sure it is world-readable and in your sorrel
        public_html directory

        (chmod 644 blah.php)

    *   if a user abc23 puts a file myfile.php in his/her public_html
        directory, its URL would be the following:

        http://www.humboldt.edu/~abc23/myfile.php

*   note: you separate PHP statements with semicolons...

*   next example: "the most famous PHP script", acc. to the
    PHP simple tutorial...  try_phpinfo.php

*   more PHP language basics...

    *   variables: named starting a $ followed by a character
        (and 0 or more letters, digits, underscores)

        a la Perl, some UNIX shell scripting languages

    *   no type declarations needed - just stick the value in

    *   assignment:   $variable = <desired expression>;

    *   see varplay.php example for more variable and string syntax...