Include all PHP classes on every page

Discussion in 'PHP' started by crazyFoo, Jul 16, 2008.

  1. #1
    I'm just starting to dive into PHP Classes. I was wondering what some best practices are.

    I would like to create all of my PHP Classes in one file (myClasses.php for example), and then include that on every page. This way, I would have access to all of my classes whenever I need them.

    Are there any problems with going this route? Does it eat up server memory? Is there a better way?

    Thanks.
     
    crazyFoo, Jul 16, 2008 IP
  2. ipro

    ipro Active Member

    Messages:
    101
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #2
    It's easier to manage and maintain classes if they all have their own files. I personally include_once(); my classes when and if I need them, otherwise it's a waste of resources.
     
    ipro, Jul 16, 2008 IP
  3. crazyFoo

    crazyFoo Peon

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the reply. What kind of resources are wasted? Server memory? I'm just trying to better understand how all of this stuff fits together.

    So in general, most people have a separate file for each class. Is that correct?
     
    crazyFoo, Jul 16, 2008 IP