PHP: Making the Internet Yours - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

PHP: Making the Internet Yours

Description:

PHP: Hypertext Preprocessor is a fairly new language, evolving from a set of ... { if ($_POST[ my_name'] != 'Easter Bunny') { #This is where we changed the script. ... – PowerPoint PPT presentation

Number of Views:90
Avg rating:3.0/5.0
Slides: 17
Provided by: elementa
Category:
Tags: php | bunny | easter | internet | making | yours

less

Transcript and Presenter's Notes

Title: PHP: Making the Internet Yours


1
PHP Making the Internet Yours
Kiel Howell Neil Farland Michael Schroeder
2
Introduction
  • PHP is an interpreted language. The code is run
    directly from the file, uncompiled just like
    Python.
  • PHP is used on many operating systems and
    architectures, though we used CentOS for our
    demonstrations.
  • PHP provides extensive extensions, including
    documentation, on the official website
    http//www.PHP.net/ .
  • PHP Hypertext Preprocessor is a fairly new
    language, evolving from a set of Perl scripts
    into the language to beat for creating
    interactive websites.
  • PHP is also useful in developing server-side
    applications, such as interfacing with a database
    via a web page.
  • Often seen on Apache or Linux servers,
    interacting with SQL databases. Together with
    PHP, this forms the LAMP (Linux, Apache, MySQL,
    PHP) architecture, a very common server setup.
  • PHP is an open-sourced language. Many
    programmers contribute to PHP, leading to a wide
    array of important contributions and, sometimes,
    increased ambiguity in syntax.

3
History of PHP
  • Created in 1995 by Rasmus Lerdorf, as Personal
    Home Page / Forms Interpreter, or PHP/FI. It
    was not a true language yet rather, it was a set
    of humble Perl scripts.
  • Was expanded upon through the open-source
    community, mostly using C to allow for
    communication with databases and creation of
    dynamic content.
  • PHP/FI 2.0 and PHP 3.0 were released in 1997,
    the latter written by Andi Gutmans and Zeev
    Suraski for the creation of eCommerce websites.
  • PHP re-named to PHP Hypertext Preprocessor.
  • PHP 3.0 was extremely extensible and
    communicative, with stronger syntax and better
    object-oriented programming capabilities.

Rasmus Lerdorf
4
History of PHP (cont)
  • In winter 1998, Gutmans and Suraski begin
    rewriting PHP from the ground up, aiming to
    improve performance and modularity. This became
    the Zend engine in 1999, named after a fusion
    of their first names.
  • PHP 4.0, based on the Zend engine, was released
    in 2000. It was far more efficient, had wider
    support for web servers, output-buffer
    capability, enhanced security for user input, and
    multiple new constructs.
  • PHP 5.0, still based on the Zend engine, was
    released in July of 2004 and remains the most
    current iteration. New to this version stronger
    exception handling, a Standard PHP Library (SPL),
    enhanced XML support, greater object-oriented
    programming, embedded SQL Lite and SimpleXML.

Andi Gutmans
Zeev Suraski
Purpose of PHP
  • PHPs purpose is simple Web design. Its server
    side, cross-platform, HTML-embedded, all to
    further web design.

5
SQL
  • SQL (Structured English Query Language) is the
    widest-used relational database language. It is
    easily learned, used, and maintained as anyone
    who has taken Intro to Databases knows.
  • SQL is not Turing complete, though it has a
    grammar, a syntax, programmatic purpose and
    intent.
  • SQL (or, rather, MySQL or PostgreSQL) is
    embedded into the code of PHP, and are often used
    hand-in-hand much of what is done with PHP is
    simply displaying database results in a pleasant
    manner.

Apache
  • Apache is a free, open-sourced, cross-platform
    project used for many web servers today. It
    allows for authentification against DBMS
    databases and GUIs, and is the most common web
    server used with PHP (and in general).

6
Variables
  • PHP variables are indicated by a dollar sign
    that is, the first character in any variable name
    must be . Variables need not be formally
    declared, and are loosely typed.
  • Variables in PHP are of dynamic scope. If
    declared within a function, a variable can only
    be accessed within that function, unless
    specifically declared global. If declared within
    a class, the variable is visible and usable by
    all functions within that class. Variables
    declared outside of functions and classes are
    global.
  • Variables are case-sensitive, although keywords
    and functions, both user- and built-in-, are not.
  • All variables can be tested as a Boolean.

Basically, beyond the initial , you can work
with PHP variables just as you would work with
variables in Python.
7
Data Types
  • PHP supports a few primitive data types
    Integers, Floating point numbers, strings,
    arrays, and booleans.
  • PHP strings are dynamic in length, and built-in
    to the core code of PHP. They must be surrounded
    by double quotes like this to be recognized as
    a string. You can use variables and HTML within a
    string, as in the previous example.
  • PHP arrays, like other variables, must begin
    with the . Individual elements can be accessed,
    as PHP arrays work much like Python dictionaries.
    PHP 5.0 allows for easy iteration over arrays.

Comments
  • Comments are handled just like in C or as in
    Python.

8
Functions and Decisions
  • Functions and decisions are, again, used much
    like in other languages. PHP functions, both
    user-made and built-in, will be very familiar to
    Python programmers, whereas the decision
    statements (If, While, For) are ripped straight
    from C.

9
Input/Output
  • Because PHP is designed to build web pages, a
    user has to have a web page to input information
    into (also, a .php file, when run, creates a
    .html file to display its results). Because of
    this, anything more advanced than the previous
    examples requires at least some knowledge of
    HTML. Forms, buttons, text boxes, and the like
    are all necessary tools. Things like CSS,
    Javascript, et al are not necessary, but are
    helpful in making anything truly complex and/or
    pretty.

10
Exception Handling
  • There is no try/except duo in PHP, so you have
    to use an if-correct, else-error setup wherever
    you expect errors to pop up (such as getting a
    string when asking for numbers).
  • In that else-error section, you can use the
    built-in die() function to make the script print
    out an error message and quit running.

11
Object-Oriented PHP
  • PHP only became somewhat object-oriented with
    version 3.0, and only strongly so with the most
    recent revision, 5.0 . Below is a simple example
    of a class.
  • PHPs classes and functions work very similarly
    to those of other languages.

Example of a Car class mostly stolen from
Wikipedia. It was too perfect to not.
12
Libraries
  • PHP has a number of libraries already built into
    it, so theres no need to reinvent the wheel.
    Weve nowhere near the time required to talk
    about them, so well simply list them (thanks,
    Wikipedia, for the list!).

13
(Possibly) Cool Examples of PHP
  • We have to minimize the Powerpoint to show you
    the stuff we did with PHP, so hold on a second
    while we poke around and load it up.

14
Whats Not So Great About PHP?
  • Variables dont have to be initialized, and
    theres no strict type-checking.
  • There may be too many (3,000!) built-in
    functions, with quantity destroying quality. Some
    consider it impossible to effectively code in PHP
    without a resource at-hand.
  • Older built-in libraries and functions do not
    use any standard format for their names (IE,
    noun_verb(), verb_noun(), studlyCaps() and
    under_scored() ), though newer libraries do
    follow a standard.
  • PHP has significant security issues regarding
    cross-site scripting and default variables.
  • PHP can be so uniquely configured to one
    particular server that code written for that
    server cannot be ported elsewhere.
  • PHP5 is not totally backwards-compatible with
    PHP4.
  • Not all libraries and extensions are thread-safe.

15
Any Questions?
16
References
"PHP Hypertext Pre Processor." PHP. 20 Apr.
2006. 5 Mar. 2006 . Sebesta, Robert
W., and Robert W. Sebesta. Concepts of
Programming Languages. 6th ed. Boston, MA
Addison Wesley, 2003. Wales, Jimmy. "Wikipedia".
3/10/06 . Williams, Hugh E.
Web Database Applications with PHP MySQL. Ed.
David Lane. 2nd ed. Sebastopool, CA O'Reilly,
2004. Welling, Luke, and Laura Thomson. PHP and
MYSQL Web Developments. 3rd ed. Indianapolis, IN
Sams, 2005.
Write a Comment
User Comments (0)
About PowerShow.com