Jump to content

Archived

This topic is now archived and is closed to further replies.

Stinger

Single file websites

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

- Orca
Site Admin, Furious Lobster

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.