1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

using include()

Discussion in 'PHP' started by heapseo, Jan 11, 2006.

  1. #1
    I have a footer file which causes some pages on a site of mine to load slowly. I currently just have include('footer.inc'), is there a way to get the rest of the page to load first rather than having this footer file delay the loading of the whole page?
     
    heapseo, Jan 11, 2006 IP
  2. onlyican.com

    onlyican.com Peon

    Messages:
    206
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Just add

    include ("footer.php");

    But at the bottom of the page
     
    onlyican.com, Jan 11, 2006 IP
  3. heapseo

    heapseo Peon

    Messages:
    636
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thats what i have at the moment and what is causing the WHOLE page to load slowly
     
    heapseo, Jan 12, 2006 IP
  4. Perrow

    Perrow Well-Known Member

    Messages:
    1,306
    Likes Received:
    78
    Best Answers:
    0
    Trophy Points:
    140
    #4
    flush();
    ob_flush();
    include('footer.inc');
    PHP:
    Should send your visitors everything up to the footer before processing the footer.
     
    Perrow, Jan 12, 2006 IP
    heapseo likes this.
  5. stuw

    stuw Peon

    Messages:
    702
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #5
    This could be an html related issue if you are using tables for your layout.

    Some browsers don't show the contents of a table until the whole of the html table and content has been loaded - sounds a bit daft. But if your whole page is a table then nothing shows until everything is loaded.

    it may be a simple case of stop using tables for layouts, or break up your page design into horizontal tables eg one for the header, one for the middle and one the footer.

    Or of course the post above works for me
     
    stuw, Jan 12, 2006 IP
    heapseo likes this.
  6. heapseo

    heapseo Peon

    Messages:
    636
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thinking about it, thats probably it - I will check it out, thanks for the suggtestion.

    I will also try the flush suggestion, thanks for that too!
     
    heapseo, Jan 12, 2006 IP
  7. UrbitasMedia

    UrbitasMedia Peon

    Messages:
    56
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Does your footer.inc include any Adsense, Adbrite or other ad hosting services. I've seen my pages take for ever to load waiting on the Adbrite ads to be displayed.
     
    UrbitasMedia, Jan 17, 2006 IP
  8. dave487

    dave487 Peon

    Messages:
    701
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #8
    If you are making a remote connection to an ad service or any third party you may want to add ini_set (default_socket_timeout, "3"); before the connection is made.

    This means the maximum delay is 3 seconds before the attempt is aborted.
     
    dave487, Jan 18, 2006 IP
  9. heapseo

    heapseo Peon

    Messages:
    636
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #9
    its sorted now, i just rearranged my tables so that everything before the footer loaded on the page without the need towaitfor the footer first.

    thanks.
     
    heapseo, Jan 18, 2006 IP
  10. UrbitasMedia

    UrbitasMedia Peon

    Messages:
    56
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #10
    dave: your time out setting is really valuable. I wasn't aware that could be done. If a timeout occurs, can you have the error message return something useful, like a locally stored banner ad? I'll research this on PHP.net, but if you have any example code I would appreciate it.
     
    UrbitasMedia, Jan 18, 2006 IP
  11. dave487

    dave487 Peon

    Messages:
    701
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Sure, use this:
    
    ini_set (default_socket_timeout, "3");
    error_reporting(0);
    
    $some_url="http://www.domain.com";
    $filestring=file_get_contents("$some_url") ;
    if(!$filestring){
     echo"file could not be opened";
    }
    else
    {
     echo"$filestring";
    }
    
    PHP:
     
    dave487, Jan 19, 2006 IP
  12. miko67

    miko67 Well-Known Member

    Messages:
    769
    Likes Received:
    59
    Best Answers:
    0
    Trophy Points:
    120
    #12
    Hehe.. speaking of which, please refer to "<DIV> vs <TABLE>" and remember to cast your vote.

    [edit] By the way Dave487: Thx for the example, might come in handy.[/edit]
     
    miko67, Jan 19, 2006 IP
  13. toby

    toby Notable Member

    Messages:
    6,923
    Likes Received:
    269
    Best Answers:
    0
    Trophy Points:
    285
    #13
    Last my my site was slow to snail. After playing with the code, i realise it is due to JAVASCRIPT from clicksor. Watch out for javascript!
     
    toby, Jan 21, 2006 IP
  14. stuw

    stuw Peon

    Messages:
    702
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Hard to belive but someone red repped me for this, a number of weeks after the thread starter green repped me for solving his problem. Silly Billies :D

    Come on people. If someones knowledge is flawed then share with everyone else in the forum, that's what threads are for....
     
    stuw, Jan 21, 2006 IP
    Perrow and miko67 like this.
  15. miko67

    miko67 Well-Known Member

    Messages:
    769
    Likes Received:
    59
    Best Answers:
    0
    Trophy Points:
    120
    #15
    Not to worry friend. We got your back ;) :D
     
    miko67, Jan 22, 2006 IP
  16. Important

    Important Peon

    Messages:
    87
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #16
    That's where php execution timers come handy :rolleyes:
     
    Important, Jan 22, 2006 IP