Thread: Includes slow?

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    60
    Rep Power
    15
    I don't know if they are or not, but do includes significantly slow down a PHP script or take CPU time on the server? In my case, I'd include a script like 20 times in a page and the include has 10 lines or so.

    Thanks!
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    It depends on whether you use includes or requires. Never use include() inside a loop as the file will be read each time the loop executes. Include()d files are read only when the code reaches the point of the include(). Require()d files are read in and basically become part of the code on the first interpreter pass so the only significant hit is the filesystem time to read the file.

    Include() is good if it's inside a conditional and the file may or may not be needed depending on the conditional... as long as the conditinal is not part of a loop, otherwise stick with require().

Similar Threads

  1. Virtual includes on Apache
    By scottyfinn in forum Apache Development
    Replies: 1
    Last Post: January 18th, 2004, 04:56 AM
  2. optimal slow query time and other
    By entropia in forum MySQL Help
    Replies: 1
    Last Post: November 6th, 2003, 09:03 AM
  3. Variable scope & recursive includes
    By kingromes in forum PHP Development
    Replies: 0
    Last Post: January 21st, 2003, 12:03 AM
  4. A simple app written in C#/VS7 has very slow GUI
    By yken in forum .Net Development
    Replies: 1
    Last Post: August 12th, 2002, 08:29 AM
  5. using includes
    By twcinpa in forum PHP Development
    Replies: 2
    Last Post: April 10th, 2002, 12:43 PM

IMN logo majestic logo threadwatch logo seochat tools logo