Re: Structuring large PHP programs

From: Date: Wed, 14 Feb 2001 21:26:25 +0000
Subject: Re: Structuring large PHP programs
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-39743@lists.php.net to get a copy of this message
I'd go w/ functions. You can split the functions into as many files as needed but I wouldn't embed their inclusions in a switch statement. I'm not quite sure what you need the switch statement for so am assuming it's part of your applications logic. I'd never write a program as one giant clump of code. It should always be broken down into functions for easy growth and porting. :) John McCreesh wrote:
What is the best practice for structuring a PHP program which is becoming too large to manage as a single file? Should it be broken into a number of includes, e.g.: switch ($whatever) {
    case 0:
        include('case0.php');
        break;
    case 1:
        include('case1.php');
        break;
    case 2:
        include('case2.php');
        break;
} or a number of functions: require('mylib'); switch ($whatever) {
    case 0:
        case0();
        break;
    case 1:
        case1();
        break;
    case 2:
        case3();
        break;
} Any thoughts, references to articles (couldn't find anything in PHPBuilder), etc gratefully received... Thanks - John


« previous php.general (#39743) next »