Re: include vs. function
| From: | jeremy brand | Date: | Wed, 23 Aug 2000 07:12:38 +0000 |
| Subject: | Re: include vs. function | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-13098@lists.php.net to get a copy of this message | ||
You may find over time that using includes is best for only containing
code that doensn't print anything out.
Over the course of the last year and a half, I have totally migrated
from using include files for say showing a page into having include
files only contain functions and variables.
My vote is for #2, since that is how evolution has ended up happening
for me and my experiences.
You may also find that having your functions print out data may not be
as useful has having the function return your data. Be returning the
data, you can then always save the buffer for the end and set a cookie
any time, or wrap your output into say a table cell... There are many
examples, and I could go on and on.
For the most part, I try and make my PHP be C code. It makes is very
readable, very logical. Personally I think it is sloppy to get in a
habbit of including files throughout a file as opposed to having a
function do it for me.
But, those I guess are my two pennies... and are only the oppinions
of me, myself and I.
-jeremy brand
_______________________________________________________________________
GnuPG Fingerprint: 9F5E 95E0 1CC2 E054 84EA 6099 8ACD 9DBA D2C0 5EA9
_ http://www.JeremyBrand.com/Jeremy/Brand/Jeremy_Brand.html
for more __
> Hey all,
>
> I am wondering as far as performance which would be better?
>
> #######
> # Scenario 1
> #######
>
> include("file.php");
> include("file.php");
> include("file2.php");
> include("file2.php");
>
> #######
> # Scenario 2
> #######
>
> include("file.php");
> function1();
> function2();
> function1();
>
> I don't know the internal workings of php. But I see a few possible outcomes
> here. In Scenario 1 it loads each include into memory and caches all of
> them, Quickly eating memory. OR it loads 1 of them in to memory dumps it,
> gets it again, dumps it, etc. Causing a lot of disk I/O and causing a
> potential bottleneck. I think you can imagine all the possibilities here. So
> what would be best?
>
> Thanx,
> Jess
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>