Welcome to the Graphic and Web Design Forum


your forum for all things Design


  •  » Graphic Design
  •  » Web Design
  •  » Logos and Branding
  •  » Illustration
  •  » Photography
  •  » Design Tutorials
  •  » Plenty of Off Topic Chat

Register now to remove this ad box


YES! I want to register an account for free right now!


-->

Thread: PHP Includes

  1. #1

    PHP Includes


    REGISTER TO REMOVE ADS


    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:
    <?php
    $companyname
    ="Test Ltd";
    $companyemail=me@meme.co.uk;
    $footer="Copyright 2007 Test Ltd";
    $cssdir="css/site.css";
    ?>
    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.

    Enjoy

  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: yoursite.com/welcome.html

    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: yoursite.com/title.htm can see its contents whether it be code or not.

    However, if that person types: yoursite.com/title.php, 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 // www.benshu.ch

  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

    REGISTER TO REMOVE ADS


    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:

    Code:
    
    
    
    
    
    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 05:25 PM.
    Evolving with style // www.benshu.ch

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
  •  

Log in

Log in