Welcome to Virtual Tutorial World Guest!



Including Files

 
Post new topic   Reply to topic    VTW Forum Index -> PHP
View previous topic :: View next topic  
Author Message
Please Register and Login to this forum to stop seeing this advertsing.





Tokens:


Posted:     Post subject:

Back to top
computergeek67
Administrator
Administrator


Joined: 31 Jul 2007
Posts: 144


Tokens: 147
Location: US

PostPosted: Tue Oct 09, 2007 7:31 pm    Post subject: Including Files Reply with quote

One of the main reasons a lot of people get into coding PHP, is the ability to include files. This will save a lot of time in the long run, and allow you to update pages much more efficiently. In this tutorial, we will be learning the main four different ways of including files.

<? include("file.php"); ?>

Include{} is the easiest method of including. It does exactly what it says, and simply includes the specified file.

<? include_once("file.php"); ?>
Include_Once{} is a little more advanced. Primarily it does the same as Include{} does, except that it includes the file only once. For example, if you had the script to include file.php and then the same script another 30 times, it would still only include it once.

<? require("file.php"); ?>

Require{} is the same as Include{} except that it will stop the page loading if it cannot load file.php. Require{} will halt the loading of the rest of the page, is the specified file cannot be included for some reason. This is useful if the file your trying to include is a vital part of the page.

<? require_once("file.php"); ?>

Require_Once{} as im sure you have guesses is a mixture of Include_Once{} and Require{}. It will include the file only once, but will halt the loading of the rest of the page, should the file be unloadable.

It is entirely up to you which including method you use. However, most proffesinal programmers will reccomend you use the require function, as pages probably should not display if there is a fatal error on the page as well.

You should also be aware that the file your including does not have to have a .php extenstion. You can include any file, from a .html to a .png should you want to.

-Thanks to DannyIsOnFire from Newgrounds



_________________



Come to me if you have any questions
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    VTW Forum Index -> PHP All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Card File  Gallery  Forum Archive
Powered by phpBB © 2001, 2005 phpBB Group
Virtual Tutorial World ©2007-2008 computergeek67

Affiliates