Introduction to PHP Difference between HTML and PHP

  • You are here
    Home » Introduction to PHP Difference between HTML and PHP
    Introduction to PHP Difference between HTML and PHP



    When you know HTML which is efficient enough to make a website.
    Why we need PHP?

    What is PHP?

    For instance, when we use google we enter the search string in
    the text field it is not possible for each result to be present in that page.

    The request is sent to server and the appropriate results is filtered and shown in the result page. This is not possible using only HTML.


    One more example is if you are showing time or date in your website.

    It is practically impossible to show updated time to the visitor
    browsing your Site. However this could be made possible using a
    dynamic web development language(php,asp.net,asp,jsp etc)
    which automatically updates your time displayed in your Site.


    PHP Code Runs in Server and not in Browser.
    For Example.

    Copy the Following HTML Code in text-editor (Notepad) and
    save it with name hello.html

    <html>
    <head><title>My First Page</title></head>
    <body>Hello World</body>
    </html>



    Make Sure its hello.html and not hello.html.txt
    Now you can open this File on Browser(Internet Explorer, Mozilla , Chrome , Safari)

    You will see something like this Hello World with white background

    Now you can Right Click on Browser and click on "View Page Source" or "View Source" or "Source Code" As per Browser.
    And you will see the above code again

    <html>
    <head><title>My First Page</title></head>
    <body>Hello World</body>
    </html>

    which you had saved in text editor with .html ext.
    Now we will give the same output using PHP.

    Note: To Run PHP Code in your Machine you need to install PHP Server in your Machine
    if you dont have it you can Learn how to Install PHP Apache Software(Xampp) and Run PHP in Windows or
    Learn how to Install(LAMP) and Run PHP Code in Linux

    Copy the Below Code in text-editor (Notepad) and
    save it with name hello.php (Place it in your Web Server Directory "c:\\Xampp\htdocs\hello.php" (Xampp) or "/var/www/hello.php" (Lamp)
    or depends on which php software you using with its particular www directory)

    <html>
    <head><title>My First Page</title></head>
    <body><?php echo"Hello World" ; ?></body>
    </html>

    Now you can open Browser(Internet Explorer, Mozilla , Chrome , Safari) and type url "http://localhost/hello.php"

    You will see somethig like this Hello World with white backgound again.

    Now you can Right Click on Browser and click on "View Page Source" or "View Source" or "Source Code" As per Browser.

    And you will see the above code which is different from the one you typed in file hello.php
    this implies the code between <?php ?> is processed and run in server and then the code is thrown to browser.

    <html>
    <head><title>My First Page</title></head>
    <body>Hello World</body>
    </html>

    Article Source:www.Planetghost.com


    Share/Bookmark
     
    Copyright (c) 2016 programmertrends