Hi,
Would like to know what's the largest PHP script you've come across..Is 200Kb script consider massive?
The thing is that i 'm currently coding a script that i think will at least take up 200Kb...is it ok π
If it was all in one file I'd be worried about the design quality.
Originally posted by Weedpacket If it was all in one file I'd be worried about the design quality.
It's all in a .php file..
Maybe i can hear the advice of the experts hereπ
My current situation is that i'm coding a script of my game and it will execute the desired option (from 50+ options ) chosen by the user. Therefore i'm coding 50+ IF clauses with quite a few query statments in each IF loop. Right now i'm trying to see if the repeated codes can be grouped as a function so as to minimise the size of php file. Any advice of how to minimise script size except functions..
...except functions..
π Do you mean like "strpos()", "mysql_query()", or "isset()"?
I guess you could remove all spaces and newlines.
Now, how to write a book without using paragraphs...
Edit: Oops. I just noticed you asked for expert input. Disregard.
Hehe, 50 IF's is NOT good programming. Use 'switch' instead π
Originally posted by Installer I guess you could remove all spaces and newlines. Now, how to write a book without using paragraphs... Edit: Oops. I just noticed you asked for expert input. Disregard. [/B]
Originally posted by Installer
Edit: Oops. I just noticed you asked for expert input. Disregard. [/B]
Don't worry, Installer. You are all experts in respective fields, so every single comments will be appreciated. You mentioned that deleting of newlines and spaces...does it mean that the file size will decrease if i transform the following from:
if (...){ $x=1; $y=2; }
to:
Yes, but the size of the file doesn't have anything significant to do with how the program behaves.
And now for some input from an expert in his respective field:
Assuming that only the computer Δ and program complexity measure Ω are of interest, it appears that we have before us some connected sets which are in a very strong sense perfect sets. For there are γ-connected sets which Δ must compute very slowly. For such sets, the term sγ/size is negligible compared with t.
Sorry, kcgame, I was being facetious about the spaces and newlines. My badly-presented point had to do more with functions. Using them along with classes and include files in a thought-out, coherent way is probably the best way to keep your programs manageable, readable, extensible, robust, etc.
What does anyone have to say about splitting up different areas of scripts into corresponding files? Such as creating and moving common SQL queries/procedures used in the script, including any and all other SQL-related commands, to a file called "mysql.php" to be included in a "main" PHP file. You could then sort out all of the echo() commands, like common error messages, success screens, output templates, convert them to constants, and move them to "constants.php" and so on.
Originally posted by bradgrafelman What does anyone have to say about splitting up different areas of scripts into corresponding files? Such as creating and moving common SQL queries/procedures used in the script, including any and all other SQL-related commands, to a file called "mysql.php" to be included in a "main" PHP file. You could then sort out all of the echo() commands, like common error messages, success screens, output templates, convert them to constants, and move them to "constants.php" and so on.
I'd say that makes sense; keep all the closely-related functionality together, and split apart the parts that don't have much to do with each other. Then you need only load in the bits you need if and when you need them.
From there it's a short walk to object orientation.
But even so; fifty if-elseif's - if you pick one if statement, then that's forty-nine statement blocks that are being loaded and parsed for no reason whatsoever. include() can be used inside if statements...