Stinger Posted May 15, 2006 Share Posted May 15, 2006 Hi,I've been coding for about a year now, made a few simple sites for friends/family.I recently made a forum script from scratch, and also an album script.To keep things simple, everything is included in index.php, except a separate config.php with mysql details.The size of of my "lite version forums" index.php is about 49KB, is this acceptable for a live website? Or would it be better to be split down in separate files?Can't seem to find any documentation on sizes of index files, cheers for any help.~S Quote Link to comment Share on other sites More sharing options...
_will Posted May 15, 2006 Share Posted May 15, 2006 I don't think I have ever seen any evidence to support one method or another, but I would have to assume that having all your code in one file would slow your website down. With all your code in one file, the PHP interpreter has more code to load and process, regardless of whether or not the code is executed. If you had multiples files then only a very small portion of the code is loaded and executed. You may not be able to tell a difference on a small site, but using one file on a large site is IMHO, not only a bad programming technique, but should slow your site down. Quote Link to comment Share on other sites More sharing options...
SiC_Goat Posted May 15, 2006 Share Posted May 15, 2006 Having your code in such a fashion isn't wrong, but it is bad style. It often creates overhead and wasted code. The best method to design any application, web or not, is to have the actual page action, or code executed when the page loads, control everything while seperate objects or methods actuall get the data. This makes it so if you later desire to change teh method in which you get data you don't have to rewrite teh whole page. You only have to rewrite the actual code that gets teh data. This is often refered to as encapsulation.Suppose, for example, you get the page name from a config file.$pageName = getPageName();Then later you want to get it from a sql database.$pageName = getPageName();The point where you actually get the page name never changed, though the code that returns the page name has.- OrcaSite Admin, Furious Lobster Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.