SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    Hiding from the world
    Posts
    351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Whats the best/fastest filetype for a php include


    sorry if this is really dumb but couldn't find the answer by searching the forums.

    Whats the best/fastest filetype for a php include?. I just want to use it for a footer on all my pages.

    Thanks
    If i am a product of your imagination you should try harder!

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well if your file will have php code in it, then you need to use include()

    if your file just has html in it, echo file_get_contents() would be faster


    the name of the file doesnt matter

  3. #3
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    Hiding from the world
    Posts
    351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cool. so as it won't have any php in it i can use the echo file_get_contents().

    does it matter if its a txt file or a php file. Are there any disadvantages to using the above compared to include().

    thanks
    If i am a product of your imagination you should try harder!

  4. #4
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the file ext means nothing to php. but personally, i would recomend using a file ext that corresponds to the contents. if it has html in it, use .html. if it has php in it, use .php

    include parses the file for php
    file_get_contents() simply returns you the contents, unparsed, faster.

    use the right tool for the situation.

  5. #5
    SitePoint Addict gl3nnx's Avatar
    Join Date
    May 2005
    Location
    at http://www.gl3nnx.net
    Posts
    343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is file_get_contents() workin on pHP 4.x.x??

  6. #6
    Wadge! F4nat1c's Avatar
    Join Date
    Oct 2005
    Location
    South Wales, UK
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    file_get_contents was introduced in PHP 4, and has been working until the current version (5.1.2).
    OMFG SitePoint ROXORZ TEH BIG ONE111!
    Wish you were invisible?

  7. #7
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    Hiding from the world
    Posts
    351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. It seems to be working perfectly on my site (php 5 i think), so i'll think i'll stick with it. Hopefully its a little easier to manage my site and a tiny bit less strain on the server.

    Thanks again.
    If i am a product of your imagination you should try harder!


Bookmarks

Posting Permissions

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