
Solid, safe website tools.
Whatever your need, Will Bontrager builds powerful software solutions.
|
(Get Attention Ticker for your web site)
PHP Include Files Save Website Maintenance TimeBy Jackie McCutcheon PHP is available on most web servers, now, and even if you don't know the PHP programming language, the "include" functions that PHP offers are easy to implement. The first PHP "include" function we will look at is this:
<?php include("filename.php"); ?>
You can use this function to create headers, standard menus, footers, etc. that can be reused on many web pages. Make a standard menu file you want all your web pages to include, put that section in a separate text file, and "include" it on any page. You can easily change the separate menu file and the change appears on all pages. The need to update all of the links on each web page is eliminated.
Example: First create a file and name it, for example, topmenu.php. It might look like this: <p><a href="http://www.example.com/index.php">Home</a> | <a href="http://www.example.com/about.php">About</a> | <a href="http://www.example.com/contact.php">Contact</a></p> Here is an example web page code that includes the topmenu.php file:
<html>
<body>
<?php include("topmenu.php"); ?>
<h1>Main Title</h1>
<p>Main content</p>
</body>
</html>
You can see how you'll save time using include files. Just update the content in the topmenu.php file if you change the links or need to add another link to the menu. If the included file (topmenu.php in our example) is in a directory different than where the web page is located, then the path to the included file must be specified along with the file name. The included file may also contain PHP code. We will be looking at other "PHP" include functions as time goes on. Stay tuned. Related post: March 22, 2008 Please note: Articles on this website are presented "as is". However - If you have a question about a CGI script, HTML, CSS, PHP, or JavaScript
Rate this blog post.
No page reload! |
|
|
© 1998-2001 William and Mari Bontrager |
|