On Thu, 5 Jun 2003 10:25:01 +0100, Bix wrote:

>My file is currently 1200 lines long and consist of 450 lines of case
>statements and then the rest are functions.

Obviously there are ways to optimize the code for speed.  However, as
with many optimizations, there are trade offs...  One way to do away
with the 450 lines of case would be to use a BUNCH of include modules. 
For instance:

<?PHP
  include "standard_lib.php";
  include "/functions/" . $_POST['Opt'] . ".php";
?>

What this means is that you would need a "Function" file for each
option in your directory with only the code for that function.  It
would be included when the "Opt" function matched.  Of course, you
would need to either see if the file exists or catch the error if it
doesn't but you just compressed 450 lines of case into 2 lines.  You
also probably compressed 2200 lines down to about 120 or so lines (3
lines for the driver, 80 for the standard includes and another 20-40
for the main function).

The down side to this is that you have to have 100+ php files that you
will have to maintain separately.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to