A Simple PHP Include Tutorial
When it comes to designing a website, there are a lot of factors which, when combined, will give the end-user a great experience. Some of these common factors include:
- Usability
- Readability
- Functionality
- Navigation
- W3C Compliance
- etc…
If you have been doing web design for any period of time, you know that the speed of editing becomes more important – in a direct correlation to how big your website is. This is where the beautiful PHP Include option comes in handy. For those of you that have never used it or heard of it, this is what it is.
A PHP Include is of course, written in the programming language of PHP. An include allows you to insert this piece of code, onto every webpage you own. You then place regular HTML code into the include file. Whenever your PHP Include is called on the page – you can have your HTML displayed.
What is this good for? It allows you to put something on thousands of pages, and only have to edit one file. What is the opposite of this? You could open up every webpage and edit the same file over and over again… but who wants to do that?
So here’s how it works…
- When working in your web design program, you can cut/paste the HTML from one spot that you need on every page, and paste it into a completely blank document (that means no HTML markup at all – the best way to make sure is to view the source code of the page).
- Save the page with a memorable name and have it end in the “.inc” extension. So if your page-name was “orderbutton”, your file would be “orderbutton.inc” (do NOT have it end in .htm or .html)
- You will then place the following code on your web-page, into the spot where you want your file to appear: <?php include(“path-to-file.inc”); ?>
Now if you are completely new to PHP, this may seem overwhelming so let me explain a bit further…
You are going to replace the “path-to-file.inc” above with the destination to your “.inc” file on your website. So if you had created a PHP include file called “orderbutton.inc” in a folder called “php”… your code would read <?php include(“php/orderbutton.inc”); ?>.
Also keep in mind, that for each sub-folder you create, your path file will change by “../”. So if you had a folder on your website that was called “products” and inside that folder you had another folder called “specials”, your PHP include code for any web-pages inside the “specials” folder would be <?php include(“../php/orderbutton.inc”); ?>.
This is how great websites are made – by simplifying the redundant tasks of editing over and over again. I hope this helps you – and if you have any questions, please ask!
How To Build A Website
A lot of people are looking around the internet and they want to know how to build a website. Websites are so popular in today’s society, that everyone from your brother to grandma, to your parents, either has their own personal web-page or perhaps they have a Facebook profile or maybe they have a MySpace page or something. Regardless of what they are using it for, it is just that everyone wants to have their own website. So this brings up the question of how to build a website. How do you go about doing it, what’s involved, and what does it take? So let’s look at the basics of how a website is put together.
There are a few options you can choose from. You can either host your particular website with a free service such as Yahoo, or if you want to spend the extra $100 bucks a year, you can have your very own website and make it look professional. It isn’t shared on any other service and it is just your site appearing alone. This is the recommended option. The service I use is HostGator and if you don’t know how to put a website together from scratch and build it, you can choose from one of their pre-designed templates. Last time I checked they had over 4,000 ready made templates for you to use at the push of the button. This is a large number of designs for you to use. These designs range from business and arts, electronics, apparel, and more. Anything you can think of, they have a design ready for you to use.
The other option would be to either learn how to code your own website by simple HTML and there are plenty of free resources on beginner HTML out there on the web. You could also use a WYSIWYG editor. This is known as “what you see is what you get”. You design the web-page by clicking buttons and it creates the code for you. A good example of a piece of a software that many beginners choose to use is XSitePro. It’s known for it’s ability and ease of use to put good looking websites together. It is especially helpful for people that have no idea how to put up code or edit graphics. You basically push a few buttons and it generates these websites for you. So it’s very handy to have if you are new to putting websites together.
Overall though, building a website isn’t very difficult once you have done it a couple of times. It is just like riding a bike. Obviously the more advanced features will take some knowledge and skill, but the beginner stuff where you put up a simple web-page, a photo gallery, or do a website for your family; those aren’t hard to do. I recommend getting involved and getting your feet wet. Put up a website, see how it looks, and then go back and touch it up once you are a bit more comfortable with how the process works. So you can either get free website software included with a web hosting package, which is done through a company such as HostGator or perhaps you may want to invest in your own web software instead and host your website anywhere you want. Like I said, the beginner software I would use is XSitePro.

