AD MANAGEMENT

Collapse

BEHOSTED

Collapse

GOOGLE

Collapse

PHP Tutorial

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PHP Tutorial

    Introduction

    Up until recently, scripting on the internet was something which very few people even attempted, let alone mastered. Recently though, more and more people have been building their own websites and scripting languages have become more important. Because of this, scripting languages are becomming easier to learn and PHP is one of the easiest and most powerful yet.

    What Is PHP?


    PHP stands for Hypertext Preprocessor and is a server-side language. This means that the script is run on your web server, not on the user's browser, so you do not need to worry about compatibility issues. PHP is relatively new (compared to languages such as Perl (CGI) and Java) but is quickly becomming one of the most popular scripting languages on the internet.

    Why PHP?


    You may be wondering why you should choose PHP over other languages such as Perl or even why you should learn a scripting language at all. I will deal with learning scripting languages first. Learning a scripting language, or even understanding one, can open up huge new possibilities for your website. Although you can download pre-made scripts from sites like Hotscripts, these will often contain advertising for the author or will not do exactly what you want. With an understanding of a scripting language you can easily edit these scripts to do what you want, or even create your own scripts.

    Using scripts on your website allows you to add many new 'interactive' features like feedback forms, guestbooks, message boards, counters and even more advanced features like portal systems, content management, advertising managers etc. With these sort of things on your website you will find that it gives a more professional image. As well as this, anyone wanting to work in the site development industry will find that it is much easier to get a job if they know a scripting language.

    What Do I Need?


    As mentioned earlier, PHP is a server-side scripting language. This means that, although your users will not need to install new software, you web host will need to have PHP set up on their server. It should be listed as part of your package but if you don't know if it is installed you can find out using the first script in this tutorial. If you server does not support PHP you can ask your web host to install it for you as it is free to download and install. If you need a low cost web host which supports PHP I would recommmend HostRocket.

    Writing PHP

    Writing PHP on your computer is actually very simple. You don't need any specail software, except for a text editor (like Notepad in Windows). Run this and you are ready to write your first PHP script.

    Declaring PHP


    PHP scripts are always enclosed in between two PHP tags. This tells your server to parse the information between them as PHP. The three different forms are as follows:

    <?
    PHP Code In Here
    ?>

    <?php
    PHP Code In Here
    php?>

    <script language="php">
    PHP Code In Here
    </script>

    All of these work in exactly the same way but in this tutorial I will be using the first option (<? and ?>). There is no particular reason for this, though, and you can use either of the options. You must remember, though, to start and end your code with the same tag (you can't start with <? and end with </script> for example).

    Your First Script

    The first PHP script you will be writing is very basic. All it will do is print out all the information about PHP on your server. Type the following code into your text editor:

    <?
    phpinfo();
    ?>

    As you can see this actually just one line of code. It is a standard PHP function called phpinfo which will tell the server to print out a standard table of information giving you information on the setup of the server.

    One other thing you should notice in this example is th
    at the line ends in a semicolon. This is very important. As with many other scripting and programming languages nearly all lines are ended with a semicolon and if you miss it out you will get an error.

    Finishing and Testing Your Script

    Now you have finished your script save it as phpinfo.php and upload it to your server in the normal way. Now, using your browser, go the the URL of the script. If it has worked (and if PHP is installed on your server) you should get a huge page full of the information about PHP on your server.

    If your script doesn't work and a blank page displays, you have either mistyped your code or your server does not support this function (although I have not yet found a server that does not). If, instead of a page being displayed, you are prompted to download the file, PHP is not installed on your server and you should either serach for a new web host or ask your current host to install PHP.

  • #2
    Good introduction to PHP and what it is and how it interacts with HTML. Will you be doing some other tutorials such as coding as well? That would probably be cool for the newbies to PHP...Maybe a Hello World example.

    Comment


    • #3
      Thats a great intro.. I would appreciate if you throw some more posts in continuity to this one..

      Comment


      • #4
        awesome post Sarunasa...
        thanx a bunch for it.

        i`ve been hearing about this "php" for a long time now but never bothered to check it out !!

        as i see from your post... its actually, quite simple!! i`m gonna try it straight away & hopefully i will learn the tricks of the trade slowly but surely!!

        Comment

        Unconfigured Ad Widget

        Collapse

        Announcement

        Collapse
        1 of 2 < >

        FreeHostForum Rules and Guidelines

        Webmaster forum - Web Hosting Forum,Domain Name Forum, Web Design Forum, Travel Forum,World Forum, VPS Forum, Reseller Hosting Forum, Free Hosting Forum

        Signature

        Board-wide Policies:

        Do not post links (ads) in posts or threads in non advertising forums.

        Forum Rules
        Posts are to be made in the relevant forum. Users are asked to read the forum descriptions before posting.

        Members should post in a way that is respectful of other users. Flaming or abusing users in any way will not be tolerated and will lead to a warning or will be banned.

        Members are asked to respect the copyright of other users, sites, media, etc.

        Spam is not tolerated here in most circumstances. Users posting spam will be banned. The words and links will be censored.

        The moderating, support and other teams reserve the right to edit or remove any post at any time. The determination of what is construed as indecent, vulgar, spam, etc. as noted in these points is up to Team Members and not users.

        Any text links or images contain popups will be removed or changed.

        Signatures
        Signatures may contain up to four lines

        Text in signatures is subject to the same conditions as posts with respect decency, warez, emoticons, etc.

        Font sizes above 3 are not allowed

        Links are permitted in signatures. Such links may be made to non-Freehostforum material, commercial ventures, etc. Links are included within the text and image limits above. Links to offensive sites may be subject to removal.

        You are allowed ONLY ONE picture(banner) upto 120 pixels in width and 60 pixels in height with a maximum 30kB filesize.

        In combination with a banner/picture you can have ONLY ONE LINE text link.


        Advertising
        Webmaster related advertising is allowed in Webmaster Marketplace section only. Free of charge.

        Shopping related (tangible goods) advertising is allowed in Buy Sell Trade section only. Free of charge.

        No advertising allowed except paid stickies in other sections.

        Please make sure that your post is relevant.


        More to come soon....
        2 of 2 < >

        Advertise at FreeHostForum

        We offer competitive rates and a many kinds of advertising opportunities for both small and large scale campaigns.More and more webmasters find advertising at FreeHostForum.com is a useful way to promote their sites and services. That is why we now have many long-term advertisers.

        At here, we also want to thank you all for your support.

        For more details:
        http://www.freehostforum.com/threads...eHostForum-com

        More ad spots:
        http://www.freehostforum.com/forums/...-FreeHostForum
        See more
        See less
        Working...
        X