Results 1 to 4 of 4

Thread: PHP Includes

  1. #1

    PHP Includes

    When designing a web site the first thing you should think about is how easy do you want future edits to be..

    Well with PHP you can speed up many processes that you may do countless times..

    first thing is create a config.php
    PHP Code:
    ="Test Ltd";
    $footer="Copyright 2007 Test Ltd";
    with a basic config file you can add many more types of fields.. then on top of every page you edit add this to the very first line in your code. before the html tags etc..!

    PHP Code:
    <?php include("config.php"); ?>
    Now anywhere you want to publish your variable do this

    PHP Code:
    <?php echo $companyname?>
    Dont forget all files must be PHP extensions.
    I have found this method to save me a lot of time.. it can be used for anything and dont forget that any config.php cannot be opened in another page. if you navigate to this config file it will be blank! hiding your details!!

    Its also a good idea to do includes for your menus etc.. so a simple include tag with the pure html or css to that menu no html needed in the include and you can change all pages with the same menu from one file.


  2. #2
    good information for those in need, however one thing I noticed.

    Dont forget all files must be PHP extensions.
    You can use other extensions, but using .php extensions means the browser will interpret it as a server side script and now print out the code in a page, but you can include .html, .htm, .txt or anyother type of file

    What Im saying is for example say you have a file at:

    and that includes a file called: title.htm

    now in the title.htm file you have some things you might now want to show, then you should use title.php.

    Anyone who then types: can see its contents whether it be code or not.

    However, if that person types:, will only see stuff that is printed to the browser (stuff with for example) but other stuff wont show up

    dont know if this was very clear but hope it was.
    Evolving with style //

  3. #3
    maybe you didnt get the point.. its for dynamic content so that you can edit few lines of code on seperate pages within one file. so php extensions is needed or it wouldnt work. unless (doubt it) you have your server setup to use .htaccess files to modify mime type

  4. #4
    hehe, I do have .htaccess file so I can use .htm, .html and it get parsed as php , sorry.

    But my point about not having to use .php extension is still true, if its not dynamic or php content and you dont have .htaccess modified.

    I often use a template such as the following:

    although I tend to use .php extension for security , could be an html file, a txt file that it included.

    makes it easier to make quick changes to a whole site especially with many pages.
    Last edited by bluesage; 25-01-2007 at 06:25 PM.
    Evolving with style //

Similar Threads

  1. includes in an array?
    By Harry in forum Programming Forum
    Replies: 11
    Last Post: 18-10-2007, 11:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts