PHP Include
Files
Server Side Include(SSI) could
save you great amount of time on changing code.It makes changes
of just one file propagated throughout
the whole web site without having to edit every single file.
PHP include also have this function.
Usually, an experienced webmaster
keeps an often-changed part as a separate file, use SSI include
this file in other files.
How to Use Include Files in
PHP
Assume you have a header.html need being include in other
files. Use the following code to include header.html:
<?php virtual("/yourpath/header.html") ?>
virtual() function use the absolute path. If header.html
is in your web site root, you may use:
<?php virtual("/header.html")
?>
You may also include() function like the following:
<?php include("myfiles.html") ?>
This function uses relative path. Include() is
relative to your include_path setting
in php.ini file. If you use include(),
include() looks
first in the same directory where required page is in to see if
there is an include file, will
include the file by that name in the default include path you've
set.
The
php.ini file allows you set up an auto_prepend_file and auto_append_file files
(header & footer files) which automatically get included
on files.
But sometimes
you may not want to include a header and footer file on
a particular file.
If you use the auto_prepend_file and
auto_append_file feature,
you do not need to add any additional code to your pages. The PHP
engine will automatically add those files.
You can also choose
to take advantage of the include_path and put all included
files in this specified directories.
|