Anime Oasis Reborn
PHP Includes

Yeah, there is a million tutorials out there on PHP includes, what makes ours different? Well, we plan on breaking it down a little more, giving you more options, and how to fix possible errors rather then throwing the code at you and saying "insert url here".

What does a PHP include do? The basic idea is to place another page/code on another page or more then one page. There is more then one code to do this with. The most common PHP include:

<?PHP
include("URL HERE");
?>

URL HERE Is where you place your url. Quotations are not needed for this to work all the time either.

Another way you can write this that you dont normally see is replacing the word Include for Require. It would look like this:

<?PHP
require("URL HERE");
?>

You are able to have as many includes on a page you want.

Urls...you must place an url inside where it says URL HERE, otherwise it wont work. How this url is wrote however can be importnt with many hosts. (this is the most common way to fix the error when you type http://www. and it doesnt work)

Most people are used to writting http://www.domain.com this doesnt always work. Sometimes you must use the direct link right off your server. But what do I mean by this?

Lets say...we have 2 folders and 3 files in both so it would look like this...

  • index.php
  • home.html
  • Cat
    • spieces.php
    • about.php
    • chome.php
  • Dog
    • spieces.php
    • about.php
    • dhome.php

Cat and Dog would be the folders while there is an index and home page as well. Starting with index.php, lets say I want it to include home.html on this page, using the direct url of course.

<?PHP
include("home.html");
?>

There is no http://www. in this url at all. That was easy enough, lets say from the index.php we click on a link taking us to the home of the cats section (Cat/home.php). Home.php is the main page, but I want it to have the dog home page as well under it, creating a "pet home" page in a sense. Displaying the home page of both dog and cat on the cat home page.

But...the dog is a folder up...I can't have it "dhome.php", it shows up as not avaiable or not existing.

../ Is a command that tells you to move up one folder. We need to go to the main folder and then to the Dog folder then to the page. (up to main - > Dog -> dhome.php)

<?PHP
include("../Dog/dhome.php");
?>

You are able to move up as many folders as you want. I could even do this if I wanted to (though would be pointless...)

<?PHP
include("Dog/../Cat/home.php");
?>

Thats all there really is to know about includes. If you need more help you can use the contact form.