Jump to content


Photo

Single file websites


  • Please log in to reply
2 replies to this topic

#1 Stinger

Stinger
  • Members
  • Pip
  • Newbie
  • 6 posts

Posted 15 May 2006 - 03:35 AM

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
[url=http://ipb1p3.ifastnet.com/][/url]

#2 _will

_will
  • Members
  • PipPip
  • Member
  • 25 posts

Posted 15 May 2006 - 03:49 AM

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.

#3 SiC_Goat

SiC_Goat
  • Members
  • PipPip
  • Member
  • 19 posts
  • LocationNew York

Posted 15 May 2006 - 04:05 AM

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
I am Orca!! A very powerful whale!!!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users