Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder Apothem's Avatar
    Join Date
    Mar 2008
    Posts
    380
    Thanks
    36
    Thanked 25 Times in 25 Posts

    Viewing one file to view a page V.S. multiple files

    What's the difference (vis-a-vi performance), if any, to viewing a single file as a dynamic page compared to viewing multiple files?

    For instance:
    One File will generate the HTML code for index view, member view, UI view, etc.
    File: index.php
    Multiple Files will generate separate HTML code for index view, member view, UI view, etc.
    Files: index.php, member.php, user.php, etc.

    Edit: Oops, I meant to post this in the PHP forum.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Nothing substantial.
    Byte for byte, I'd expect that in a single file would be faster. However, it reduces the reusability of you're code, so separate files is a better option.
    For an example, I create a single file to be used as an interface or class. Though I could put multiple classes (keeping a 'group' of classes together that are similar), in the long run it would waste more space. If I only needed a 'user' type class in one project, I can save memory by not putting the 'usergroup' class in with it. Why load what we don't need?

    Programming is always about trade offs.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #3
    Gütkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    Well, Pykex, the way you are describing the situation is a bit different from the situation assumed in Fou-Lu's answer.

    The way you describe it, there's always only one php file per http request, which means that the multiple files would be a few nanoseconds faster than the single file, which would have to do some case distinction.


  •  

    Posting Permissions

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