• Hello world in PHP - Lets start coding PHP - First step

    | More


    About the Author : Gaurav Sharma

    Apologies for not writing frequently on this topic in the last few weeks due to loads of work of Vinnex and other stuff. Anyways lets start coding now....

    So once you are done with the Xampp installation , start the XAMPP now by clicking on Xampp_start.exe icon present in the Xampp folder.

    Once the xampp_start.exe is clicked , the following black window will open with following message :

    ##Apache and MySql is starting now ###
    Ok!! So the localhost server is started now. Which can be tested by opening http://localhost/ on your internet browser. First Code : Two important things to remember when you do php coding :
    • The file extension of php files is .php
    • Any php code should be written between
      <?   and  ?>
    • Each statement ends with a semi-colon i.e. ;
    • Variable name starts with a dollar sign , example $name, $username, $password
    So basic format of a php file is
    <?




    PHP CODE



    ?>
    The first command that we use in PHP to print any text is ECHO Command line : echo "MY NAME IS GAURAV" ; or echo $name; or

    Check this now >>

    $name="Gaurav";
    echo "My name is $name";


    Here we have declared a variable called $name and have entered a value in the variable equal to Gaurav. And in the next statement we printed the declaration MY NAME IS $name using echo. NOTE : GIVE SPECIAL CARE TO SEMI-COLON and INVERTED COMMAS. WHEN A VARIABLE alone is to be echoed, then no need of inverted commas.


    Now save the file as name.php in htdocs folder present in the xampp folder.



    In the internet browser, open http://localhost/name.php

    and you will get My name is Gaurav as output.



    Enter your email address to get all the scripts,php tutorials and blogging tips delievered direct to your inbox


0 comments:

Leave a Reply

Subscribe

Spread Firefox Affiliate Button

Enter your email address:

Recent Posts

Twitter Updates

    follow me on Twitter