Is it good to include unuse files?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ngocviet

    Is it good to include unuse files?

    Sorry for the noob question!
    My project have alot class files(>100), in one request I only need some
    class(1-5), but I dont like to have to specifies needed files so I make
    a include.php, that include all my class files.

    In action file, I only include the include.php! Is it good for
    performent? Does it make any problem?

    Thanks!

  • Juliette

    #2
    Re: Is it good to include unuse files?

    ngocviet wrote:
    Sorry for the noob question!
    My project have alot class files(>100), in one request I only need some
    class(1-5), but I dont like to have to specifies needed files so I make
    a include.php, that include all my class files.
    >
    In action file, I only include the include.php! Is it good for
    performent? Does it make any problem?
    >
    Thanks!
    >

    Including 100+ files while you only need 5 will always hurt your
    performance. Includes are slow.

    Even so, it shouldn't necessarily be a problem unless you run over the
    maximum execution time limit.
    Just keep in mind that users who have to wait a lot, may not stay for long.

    Comment

    • mootmail-googlegroups@yahoo.com

      #3
      Re: Is it good to include unuse files?

      ngocviet wrote:
      Sorry for the noob question!
      My project have alot class files(>100), in one request I only need some
      class(1-5), but I dont like to have to specifies needed files so I make
      a include.php, that include all my class files.
      >
      In action file, I only include the include.php! Is it good for
      performent? Does it make any problem?
      >
      Thanks!
      No, it is not good for performance, as has already been stated.

      The bright side is that you don't have to specify each include that you
      need to use seperately anymore. Have a look at autoload [1]. With
      this function, you tell php that whenever I want an ABC object, include
      the file class.ABC.php, or whatever naming convention you are using.
      This way, php only includes the files which are referenced in your
      code. Just define it in your include.php file and you'll never have to
      think about it again.
      *Disclaimer: PHP 5 only

      [1] - http://us3.php.net/manual/en/language.oop5.autoload.php

      Comment

      Working...