lecture 1-introduction to php

Upload: thirumrugan-suvarnalingam

Post on 07-Apr-2018

223 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/6/2019 Lecture 1-Introduction to PHP

    1/25

    PHP and MySQL

    Web Development

    Course Title

  • 8/6/2019 Lecture 1-Introduction to PHP

    2/25

    At the end of the course,

    students will learn how to: Write effective and efficient PHP codes.

    Embed PHP scripts in HTML pages to

    create a interactive web pages. Manipulate data from web pages forms.

    Build real-world dynamic web sites.

    Develop database-enabled webapplications using MySQL.

  • 8/6/2019 Lecture 1-Introduction to PHP

    3/25

    Requirements of the Course:

    You should have a basic understandingof the following.

    HTML/XHTML JavaScript

    SQL

    Have done some basic programming

  • 8/6/2019 Lecture 1-Introduction to PHP

    4/25

    Introducing PHP

    and MySQL

    Prepared By.Prof. Mary Grace G. Ventura

    UE-CCSS, Faculty

  • 8/6/2019 Lecture 1-Introduction to PHP

    5/25

    What is PHP?

    PHP stands for PHP: Hypertext Preprocessor.

    PHP is a widely used general-purpose

    scripting language that is especially suitedfor web development and can beembedded into HTML (http://www.php.net).

    The main goal of the language is to allowweb developers to write dynamicallygenerated web pages quickly.

  • 8/6/2019 Lecture 1-Introduction to PHP

    6/25

    What is PHP?

    PHP was conceived in 1994 and was originallythe work of one man, Rasmus Lerdorf.

    It was adopted by other talented people and has

    gone through four major rewrites to bring us thebroad, mature product we see today.

    As of November 2007, it was installed on morethan 21 million domains worldwide, and this

    number is growing rapidly. PHP is an Open Source project, which means

    you have access to source code and can use,alter, and redistribute it all without charge.

  • 8/6/2019 Lecture 1-Introduction to PHP

    7/25

    What is PHP?

    PHP originally stood for Personla Home Page,but was changed in line with the GNU recursivenaming convention (GNU = Gnus Not Unix) andnow stands for PHP Hypertext Processor.

    The current major version of PHP is 5. Thisversion saw a complete rewrite of the underlyingZend engine and some major improvements tothe language

    The home page for PHP is available athttp://www.php.net The home page for Zend Technologies is

    http://www.zend.com

  • 8/6/2019 Lecture 1-Introduction to PHP

    8/25

    Features of PHP

    As a programming language for the Web, PHP ishard to ignore.

    Clean syntax,

    object-oriented fundamentals,

    an extensible architecture that encouragesinnovation, support for both current and

    upcoming technologies and protocols, and excellent database integration are just some of

    the reasons for the popularity it currently enjoysin the developer community.

  • 8/6/2019 Lecture 1-Introduction to PHP

    9/25

    Reasons To Love PHP

    Cost

    Simplicity

    Stability Portability

    Speed

    Open Source Extensible

  • 8/6/2019 Lecture 1-Introduction to PHP

    10/25

    Cost

    PHP costs you nothing, not one red cent.

    Nothing up front, nothing over the lifetime

    of the application, nothing when its over. Not to mention that theApache/PHP/MySQL combo runs great oncheap, low-end hardware that youcouldnt even think about for IIS/ASP/SQLServer?

  • 8/6/2019 Lecture 1-Introduction to PHP

    11/25

    Simplicity

    Because PHP uses a consistent and logical syntax, andbecause it comes with a clearly written manual, evennovices find it easy to learn.

    In fact, the quickest way to learn PHP is to step through themanuals introductory tutorial, and then start looking atcode samples off the Web.

    This adherence to the KISS (Keep It Simple, Stupid)principle has made PHP popular as a prototyping and rapidapplication development tool for web applications.

    PHP can even access C libraries and take advantage ofprogram code written for this language, and the language isrenowned for the tremendous flexibility it allowsprogrammers in accomplishing specific tasks.

  • 8/6/2019 Lecture 1-Introduction to PHP

    12/25

    Stability

    The word stable means two differentthings in this context:

    The server doesnt need to berebooted often.

    The software doesnt changeradically and incompatibly fromrelease to release.

  • 8/6/2019 Lecture 1-Introduction to PHP

    13/25

    Portability

    The ease with which a program can bemade to work on different platformsisan important factor.

    PHP users have little to fear here, becausecross-platform development has been animportant design goal of PHP since PHP

    3.0.

  • 8/6/2019 Lecture 1-Introduction to PHP

    14/25

    Speed

    PHP is pleasingly zippy in its execution,especially when compiled as an Apache moduleon the Unix side.

    The MySQL server, once started, executes evenvery complex queries with huge result sets inrecord-setting time.

    PHP5 is much faster for almost every use thanCGI scripts. There is an unfortunate grain oftruth to the joke that CGI stands for Cant GoInstantly.

  • 8/6/2019 Lecture 1-Introduction to PHP

    15/25

    Open Source Licensing

    Possibly the best thing about PHP is that itsfreeits source code is freely available on theWeb, and developers can install and use itwithout paying licensing fees or investing in

    expensive hardware or software. Using PHP can thus significantly reduce the

    development costs of a software application,without compromising on either reliability or

    performance. The open-source approach also ensures fasterbug fixes and quicker integration of newtechnologies into the core language, simply dueto the much larger base of involved developers.

  • 8/6/2019 Lecture 1-Introduction to PHP

    16/25

    Extensible

    PHPs creators built an extensible architecturethat enables developers to easily add support fornew technologies to the language through

    modular extensions. This extensibility keeps PHP fresh and always at

    the cutting edge of new technology.

    PHP lets you do through its add-on modules:dynamically create image, PDF, and SWFfiles;connect to IMAP and POP3 servers; interfacewith MySQL, Oracle

  • 8/6/2019 Lecture 1-Introduction to PHP

    17/25

    The Required Tools

    To put up your dynamic Web site, you need tohave access to the following three softwaretools:

    A Web server: The software that delivers your Webpages to the world.

    PHP: The scripting language that youll use to writethe programs that provide the dynamic functionality

    for your Web site. MySQL: The RDBMS that will store information for

    your Web database application.

  • 8/6/2019 Lecture 1-Introduction to PHP

    18/25

    Obtaining PHP For Windows

    You can easily install PHP from binary files thatyou can download from the PHP Web site atwww.php.net.

    You can download a Zip file that contains all thenecessary files or an installer that you can run toinstall all the PHP files.

    To download the Windows Zip file, take thesesteps:

    1. Go to www.php.net/downloads.php.2. Download the Zip package for the most

    recent version of PHP.

  • 8/6/2019 Lecture 1-Introduction to PHP

    19/25

    Obtaining All-in-One

    Installation Kits You can obtain some kits that contain and install

    PHP, MySQL, and Apache in one procedure.

    XAMPP is a popular all-in-one installation kit that

    contains Apache, PHP, and MySQL. It also installs phpMyAdmin, a utility for

    managing your MySQL databases XAMPP hasstable versions available for Windows, including

    Vista, and for several versions of Linux. XAMPP is available at

    www.apachefriends.org/en/xampp.html.

  • 8/6/2019 Lecture 1-Introduction to PHP

    20/25

    Obtaining All-in-One

    Installation Kits WAMP5 is a popular installation kit for Windows

    that provides recent versions of Apache 2.2, PHP5, and MySQL 5.

    Like XAMPP, WAMP5 also installs thephpMyAdmin utility.

    The WAMP5 Web site states that its compatiblewith Windows Vista.

    WAMP5 doesnt run on Windows 98/Me. WAMP5is available at www.en.wampserver.com.

  • 8/6/2019 Lecture 1-Introduction to PHP

    21/25

    How the AMP Pieces

    Work Together Its important to understand the role of Apache, MySQLand PHP play in creating your web site.

    Imagine for a moment that your dynamic web site is likea fancy restaurant.

    Hungry diners come to your place and each one wantssomething different and specific. They don t worry somuch about how the food is prepared so long as it looksgreat and tastes delicious.

    Unlike a buffet spread where everything is laid out andyour patrons just pick and choose from what s available,a nice restaurant encourages interaction between thepatron and waiter and complete customization of anymeal to meet any specific dietary needs.

  • 8/6/2019 Lecture 1-Introduction to PHP

    22/25

    Characterize the Components

    of AMP as follows: PHP: Whatever people ask for, your highly trainedmaster of culinary arts, the chef, prepares itwithoutcomplaint. She is quick, flexible, and able to prepare amultitude of different types of foods. PHP acts in much

    the same way as it mixes and matches dynamicinformation to meet the request for fresh web pages.

    MySQL: Every chef has a well - stocked stockroom ofingredients. In this case, the ingredients used by PHPare records of information stored in MySQL s databases.

    Apache: This is the waiter. He gets requests from thepatron and relays them back to the kitchen with specificinstructions about how the meal should be prepared.Then he serves the meal once it is complete.

  • 8/6/2019 Lecture 1-Introduction to PHP

    23/25

    For Further Understanding:

    When a patron (web site visitor) comes to yourrestaurant (web site), he or she sits down and orders ameal with specific requirements (requests a particularpage or resource), such as a steak served medium well.

    The waiter (Apache) takes those specific requirementsback to the kitchen and passes them off to the chef(PHP).

    The chef then goes to the stockroom (MySQL) toretrieve the ingredients (data) to prepare the meal andpresents the final dish (web page) back to the waiter,who in turn serves it to the patron exactly the way he orshe ordered it.

  • 8/6/2019 Lecture 1-Introduction to PHP

    24/25

    Reference:

    PHP and MySQL Web Development 4th edition,By: Luke Welling and Laura Thompson,2009

    PHP and MySQL Bible 2004, By Tim Converse

    How to do Everything with PHP and MySQL2005, By Vikram Vaswani

    PHP and MySQL Web Development All in OneDesk Reference, For Dummies 2008, By Janet

    Valade Beginning PHP 6, Apache, My SQL Web

    Development2009 By: Timothy Boronczyk

  • 8/6/2019 Lecture 1-Introduction to PHP

    25/25

    END