PHP is an amazing tool for any website. If you're wondering, it stands for
Post Hypertext Peripheral coding. PHP is mostly used in layouts for
websites. Before beginning this tutorial, you must know whether your web
server supports PHP! Be careful, web servers that support PHP are pretty
rare, especially free web hosts. Don't worry, PHP is very easy to learn and
doesn't even take that much time.
Step 1: Okay if you're here, then you know that your web host supports PHP.
The first thing you must do is create a simple page, with a decent layout
that you like. Make sure the layout is organized. For example, the content
is in one spot and the navigation is in the other. Now this is the really
cool and fun part. Delete all the information from where the content would
be, like the news and other main information. Don't delete the navigation
menu, or news ticker, or what other things you might have had. Simply delete
the spot where all the content would go. Take all that content, and put it
on another page and save it. Now you simply have a page with a layout, but
no content. Save that layout page as index.php or main.php, or something
easy to remember.
Step 2: Now you have an index.php or a main.php, or what you named that
layout page. The next thing you have to do is simple. Open your layout page,
<?php include ("$page.extension"); ?>, where the content once was.
So here we have a layout page with <?php include ("$page.extension"); ?>
where all the content once was. Next you have to edit that line that you
The page in the line stands as a variable. For example, DBGT.com used "dbgt"
as their variable. Make sure your variable is easy to remember, as it will
be used throughout the whole site. You could use "page" as your variable;
there is nothing wrong with it.
The extension part stands for the types of pages you used. For example, your
pages could be ".html" or ".shtml". PHP only works with page extensions such
as ".html" or ".txt". I believe there are some other ones, but these are the
most popular. So go ahead and change all your pages to either ".txt" or
".html" and where extension goes, write the one that you chose. So now, you
have something like this:
<?php include ("$page.html"); ?> or
<?php include ("$page.txt"); ?>.
Step 3: Lastly, you must test your ".php" page. Open up your browser and
type in the address to the php page. For example:
You should see the layout that you
created, but in the content area you should get a PHP error, because the
layout page doesn't know where to re-direct! This part is probably the
hardest in PHP, but it's still very simple. Remember all that content you
deleted from the layout page? You must find out what you saved it as, such
as "news.html" or "news.txt", or something else. Now go to the web address
bar, and next to index.php, make a ? and type your variable. After that,
make an equal sign, =, and write in the name of the page of your content. It
might be hard to explain, but let me give you an example. DBGT.com's
variable is "dbgt" and their ".php" page is called "index.php". Then, using
multimedia as an example, they have it as multimedia.txt. So, your address
would look like this:
That should help to clear things out a bit. You should NOT write the
extension in the address. Writing
http://www.dbgt.com/index.php?dbgt=multimedia.txt is a BIG no. Simply write
the name of the page.
Now, when you visit that page you should get your ".php" page layout and
also the page of information in the content section. That is, when you
re-direct the page. PHP might sound a little complicated in words, but once
you get the hang of it it's really cool.
You could probably see what PHP is used for now. You could simply edit your
layout page, and have a new layout, without even having to edit each and
every page in the site! See, I told you it was a great tool.