PHP Script Length

Status
Not open for further replies.
well, since its about 10 different things why not split up each function, put each in its own file and then if you have to execute it just include it ? Not only will this cut down on the size of the file, but it will also make the overall functionality of the whole thing more obvious and make it easier to change the functions. i think you answered your own question
 

torok

Ars Tribunus Militum
2,000
Originally posted by futang:
well, since its about 10 different things why not split up each function, put each in its own file and then if you have to execute it just include it ? Not only will this cut down on the size of the file, but it will also make the overall functionality of the whole thing more obvious and make it easier to change the functions. i think you answered your own question

Here is the basic structure of the code:
Code:
...
elseif ($action == 'editGroup' && !empty($submit)){...}
elseif ($action == 'editGroup' && empty($submit)){...}
elseif ($action == 'newGroup' && !empty($submit)){...}
elseif ($action == 'newGroup' && empty($submit)){...}
...

It is much easier for me to write

/cp.php?action=newGroup

then to try to figure out what script the action I want is in. So, this has convienence for me. I just want to know if PHP looses performance when file sizes are large. If so, I will forgo the convenience for the performance.
 

torok

Ars Tribunus Militum
2,000
Originally posted by futang:
im not suggesting you make the different functions the target of your url. keep your big if block but when you find the one you want import the function and run it. i doubt you'll be gaining much speed but at least from my point of view its a lot easier to work with a bunch of 100-200 line files than one monster.

Ah, okay, I get it. Good idea.
 

jeremy

Ars Scholae Palatinae
784
i'm not sure of a performance hit once it's read in and running, but there's got to be some kind of cost while php reads the scripts and parses it.

i'm not sure. why don't you write two diff scripts, one big one, and one with includes and then run apache bench on the scripts calling them about 1000 times and see which one finishes faster. it won't be a very scientific test, but i'd love to see the results.
 
Status
Not open for further replies.