Err Posted December 23, 2009 Share Posted December 23, 2009 I have a PHP page full of PHP scripts that take up 1440 lines in just one file. What I'm doing in these files is I'm adding content of different areas into it. So instead of having a login.php page, I will add it inside my index.php. As you can imagine, things get big fast. I want to know if my index.php will load slower versus including the files into it with an include function. Right now, the complete rendering time for the page that has 1440 lines of code is 0.250 - 0. 450 seconds; but this is on my localhost. Link to comment Share on other sites More sharing options...
Synook Posted December 23, 2009 Share Posted December 23, 2009 Including code will always be slower than physically placing it inside the same file. Link to comment Share on other sites More sharing options...
Err Posted December 23, 2009 Author Share Posted December 23, 2009 So loading a 90KB page is still faster then loading a page through include functions. I just don't want to get into the habit of doing that if the server is going to be loading more than what is necessary to load. Link to comment Share on other sites More sharing options...
justsomeguy Posted December 23, 2009 Share Posted December 23, 2009 It depends how your code is structured, if you have include statements inside if statements then those files will only get included under certain circumstances. If that's the case, it might be marginally faster to use include files. But if your page needs to load 90KB of code regardless of what happens, it's faster to load it all from one file than from several. Include files help a lot with cleaning your code up, if you move the page logic out of your index file it will make your index file cleaner. Link to comment Share on other sites More sharing options...
Err Posted December 25, 2009 Author Share Posted December 25, 2009 That is true. I found that having multiple files for login/edit/search functions will make tracking pages difficult and if I ever need to move the index file, I will have to move or rename the path for the files. So to make things easier for me, I have packed it all in one page and under certain circumstances I will execute the code. I am thinking my method works just like the include function which will only load and execute that code in that circumstance. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.