Re: Re: PHP includes
| From: | Sudheer Satyanarayana | Date: | Mon, 09 Mar 2009 15:46:58 +0000 |
| Subject: | Re: Re: PHP includes | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-289677@lists.php.net to get a copy of this message | ||
Gary wrote:
Thank you to everybody that replied...but it almost seems it is making extra work. I can understand using an include for a menu, since they tend to change often and it is on every page, but the normal content I am not understanding the benefit. If I have a page that has unique content on it, that is to say no other page has this content, why would I want to create a separate file to be included on the page, why would I not simple put the content directly on the page itself? There are several advantages of using include. I can't imagine an application without include/require/autoload.I create the database adapter only once per request. I store several application configuration items in a config file and load this configuration information only once per request. I have one layout for the application. Only the content and the menus change. So, I would simply include various sections of the web page in relevant positions. Example: layout.php <?php include 'header.php'; include 'menu.php'; // menu.php is also dynamic. menu.php determines what to display on the current page. include 'sidebar.php'; // within sidebar.php I would include block_a.php, block_b.php, etc include 'footer.php'; ?> I put the utility functions and classes in a library file. I would simply include the library.php and use the functions available in it. I hope you get the point of using include.
What is the best type of file to be used as an include (.txt, .php).-- With warm regards, Sudheer. S Business: http://binaryvibes.co.in, Tech stuff: http://techchorus.net, Personal: http://sudheer.net