Re: daisy chaining includes

From: Date: Fri, 26 Jan 2001 02:06:15 +0000
Subject: Re: daisy chaining includes
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-6207@lists.php.net to get a copy of this message
Thanks for all the replies. I finally made things readable. A little easier to follow now. instead of scrolling for days :} John On Tue, 23 Jan 2001 php3@developersdesk.com wrote: > Addressed to: John Starkey <jstarkey@advancecreations.com> > php-db@lists.php.net > > ** Reply to note from John Starkey <jstarkey@advancecreations.com> Tue, 23 Jan 2001 > 02:02:46 -0700 (MST) > > > > I'm trying to clean up about 2000 lines of whacked out newbie code > > i've created. Is there a way to daisy chain includes? I have about > > five includes in each header and I was thinking of making one include > > file and linking to that. And furthermore :} is there a way to > > include within a function if i do make several include files? So the > > file is only called when the function is? Would this be a good way to > > cut down on server processes? Or would it offset by the > > disk-to-parsed time? > > You can do all kinds of things with include. The key to included > functions is that the include has to happen first. The thing to > remember is that an included file is almost the same thing as cut and > past to put the same code into the program in place of the include > statement. > > > include( 'some_functions' ) > > call_function_from_file(); > > > > This one doesn't even need > if( condition ) { > include( 'file' ); > } > > else { > include( 'another_file' ); > } > > > I have a number of programs where the main php file looks like: > > > switch $Command { > > case 'do_something': > include( 'something.plib' ); > break; > > case 'do_something_else': > include( 'something_else.plib' ); > break; > > ... > ... > ... > > > To make things interesting, something.plib contains only code, and the > last thing it does is > > include( 'something.page' ); > > which is mostly html. Something.page almost always contains calls to > functiong that are defined in something.plib. Usually the functions in > something.plib call functions in something.page to display thier > results. It sounds messy, but I find it very easy to find what I am > looking for when I am working on the programs. > > > > > > > > I had a db_queries include but i've dropped that so that I can use > > one variable and unset it each time. This is a way to save memory > > right? Dumb question I think. > > Unsetting a result variable makes a little difference. In PHP4 it > would also trigger a mysql_free_result() which could make a big > difference. This only matters if it happens early in a script. A > script that does one thing and ends is not a problem, as PHP does good > garbage collection for you. The only time you need to worry about it > is when you are doing several things, and don't need to keep old > results. > > > > > Rick Widmer > Internet Marketing Specialists > http://www.developersdesk.com >

« previous php.db (#6207) next »