On Jun 29, 2004, at 9:39 PM, Gary Minato wrote:
I use the php require() function when the same content must be
included
on every page, eg
<?php require("navigation.inc"); ?>
I use include() if I need to provide options when using if, else or
other statements, eg
<?php
$request="boy";
if ($request=='boy') {
include("boy.php");
}
else {
include("girl.php");
}
?>
Note that require & include are now almost identical, as of PHP 4.0.2,
and it doesn't seem necessary to make this distinction in your case.
(Previously, require() was evaluated, even if the line wasn't
executed.)
From <http://us2.php.net/require>
require() and include() are identical in every way except how they
handle failure. include() produces a Warning while require()
results in a Fatal Error. In other words, don't hesitate to use
require() if you want a missing file to halt processing of the page.
include() does not behave this way, the script will continue
regardless. Be sure to have an appropriate include_path setting as
well.
Other useful commands are require_once & include_once, which make sure
the files are only included once -- useful if you're including a block
of functions & another included file might try to include them as
well.
Hope these help,
Tim
_______________________________________________
web-development mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/web-development
Do not post admin requests to the list. They will be ignored.