Re: [PHP-DB] daisy chaining includes

2001-01-26 Thread John Starkey

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 [EMAIL PROTECTED] wrote:

> Addressed to: John Starkey <[EMAIL PROTECTED]>
>   [EMAIL PROTECTED]
> 
> ** Reply to note from John Starkey <[EMAIL PROTECTED]> 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
> 


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] daisy chaining includes

2001-01-23 Thread php3

Addressed to: John Starkey <[EMAIL PROTECTED]>
  [EMAIL PROTECTED]

** Reply to note from John Starkey <[EMAIL PROTECTED]> 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

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] daisy chaining includes

2001-01-23 Thread Cal Evans

I have a single include file that I put all my require_once commands in that
are applicable to each page.

Something like


then at the top of each page I put:

require_once("myincludes.php");

is that what you are looking for?
Cal
http://www.calevans.com


-Original Message-
From: John Starkey [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 23, 2001 3:03 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] daisy chaining includes


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?

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.

Thanks,

John


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] daisy chaining includes

2001-01-23 Thread John Starkey

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?

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.

Thanks,

John


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]