Intro
Have you ever wanted to shorten a page that you have made, or have you ever wanted to include that other document? Well here is your chance. PHP has a couple features like "require", "require_once", "include", & "include_once". And so now you can use them to your satisfaction after this tutorial.
The Difference Between Include and Require
There is a huge difference between including a file and requiring a file. When you include a file it still imports it like they all do, but if the file does not exist or some other error, then PHP will just skip over it and pop up and error where the file messed up at. But when require fells, it stops processing the file that you loaded and displays and error, unless you have errors off in which the user will get a blank page, or they will be directed to a error document. Here is a example of each type of include.
Include
Include_OnceCode:<?php include 'index.php'; ?>
RequireCode:<?php include_once 'index.php'; ?>
Require_OnceCode:<?php require 'index.php'; ?>
It is your choice which one you want to use.Code:<?php require_once 'index.php'; ?>



LinkBack URL
About LinkBacks





Reply With Quote

Bookmarks