Jump to content

Single file websites


Stinger

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.