Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
05-03-2009, 11:57 PM #1
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?
One File will generate the HTML code for index view, member view, UI view, etc.
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.
05-04-2009, 02:14 AM #2
- Join Date
- Sep 2002
- Saskatoon, Saskatchewan
- Thanked 2,650 Times in 2,619 Posts
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');
05-04-2009, 02:24 AM #3
- Join Date
- Apr 2009
- 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.