• Practice lab for PHP Web application on Apache
  • Your First Web Server Application lab




    Download 1.41 Mb.
    Sana22.12.2019
    Hajmi1.41 Mb.

    Your First Web Server Application lab

      1. PHP

        1. Overview


    PHP is just one of many popular Web server side open source scripting languages. It is widely used for Web application development. There are over half million server pages developed by PHP. It is still growing very fast.

    PHP is often embedded into HTML to enhance functions of HTML. PHP allows you to interact with a HTML page dynamically. PHP collect data from page where user provides and then process and utilize data to create a dynamic home page output.

    PHP can do all tasks that ASP and JSP can do plus it is free. Why is PHP so popular?

    The answer is following:



    • PHP is Open Source and free

    • PHP is much compact than Java and .NET in term of its system size

    • PHP is portable and runs on Linux, Windows, and Mac platforms

    • PHP is a server-side script language easy to be adopted

    • PHP has fast connections to popular databases compared with Perl

    • PHP is integrated with the Open Source MySQL database

    • PHP is an OO interpreter language

    • PHP Web pages work with all popular major browsers

    • PHP has integrated linking to XML PDF, SWF, and Java for dynamic creation and processing

    • PHP syntax is familiar to C, Perl, and Java



    PHP marries HTML well because PHP is designed to be used along with HTML. You can embed PHP into HTML document, or put HTML tags in PHP coding seamlessly.

    In addition, PHP gets alone with MySQL very well. These two make up the best combination for data-driven Web application cross-platform. PHP can also support a massive number of databases, including Informix, Oracle, Sybase, and ODBC drivers.


        1. Practice lab for PHP Web application on Apache


    In this section, you will be given a hands-on lab on a “Hello user” Apache server and PHP Web project. A PHP based on HTTP server page is populated on an Apache Web server. If a Web client accesses this page and fill in his/her name as then the PHP page will dynamically create a response page which responds a greeting statement “Hello ”.

    After installing Apache server, you can download and install PHP with http://www.php.net/downloads.php. The installation manual at http://www.php.net/install.windows may be helpful. The binary installer is very easy to use. However, if you want to use manual installation, you need to extract the php 5.x into C:\php. You may choose a different location but do not leave any spaces in the path (like C:\Program Files\PHP) as some Web servers will crash if you do so.

    In your php directory, there are two files: php.ini-dist and php.ini-recommended. Change one of them into php.ini (php.ini-recommended is preferred).

    First, edit php.ini file as follows:

    doc_root = C:\xampp\htdocs

    extension_dir = "c:\xampp\php\ext"


    Next, edit Apache configuration file httpd.conf. Add following lines into it, the PHP would work as a module:

    ###


    LoadModule php5_module "c:/xampp/php/php5apache2_2.dll"

    AddType application/x-httpd-php.php

    PHPIniDir "c:/xampp/php"

    ###


    The Web page of http://www.ricocheting.com/server/php.html is a good getting started tutorial.

    You can create a file named test.php in your apache default folder:



    C:\xampp\htdocs
    The php template is shown as
    . . .

    phpinfo();



    ?>

    . . .


    Save your configuration and start up the Apache server. Go to http://localhost/test.php, and you will see:

    Edit the HTML template provided by PHP as follows:







    hello user





    Name:





    Hello!



    Name:







    Name:






    Download 1.41 Mb.




    Download 1.41 Mb.

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    Your First Web Server Application lab

    Download 1.41 Mb.