id: 1
Category: PHP
Rated:
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");
?>
Another way you can write this that you don’t normally see is replacing the word Include for Require. It would look like this:
<?PHP
require("URL HERE");
?>
URLs...you must place an URL inside where it says URL HERE, otherwise it wont work. How this URL is written however, can be important with many hosts. (This is the most common way to fix the error when you type http://www. and it doesn’t work)
Most people are used to writing http://www.domain.com this doesn’t 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
<?PHP
include("home.html");
?>
But...the dog is a folder up...I can't have it "dhome.php", it shows up as not available 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");
?>
<?PHP
include("Dog/../Cat/../home.php");
?>


