How Can I Include Files in my Web Page?
Tuesday, March 31st, 2009Including Files Using PHP
To include specific files into your webpage, you can use something like a PHP include() if your files are .php files or if you have your server set to handle whatever extension you are using as a PHP file.
Just insert the code into the part of the webpage you would like to include ‘name-of-file.php’ and it will automatically be inserted into the webpage when requested. (Note: ‘name-of-file.php’ must be located in the same directory as the file including/calling it, or else you must state the directory it is in: such as ‘news/name-of-file.php’ or ‘../name-of-file.php’ if it is one directory lower than the one currently in. You could also use absolute linking: http://www.domain.com/name-of-file.php.
Server Side Includes
Another thing you can try is Server-Side Includes. A server side include looks like and can be placed in the same manner as above, anywhere in your html (or whatever) file that you would like the included file to be displayed.
Includes are a great way to display something like a sidebar on every page for something that doesn’t need to be changed for every page. It will save you plenty of time.