|
Posted by Jerry Stuckle on 11/24/07 14:34
FFMG wrote:
> Hi,
>
> Please help me settle a geek argument :).
>
> I believe that php caches included code whenever possible.
> So given the 2 files bellow.
>
> // file.php
> -------------------------------------
> <?php
> $value = 'Some value';
> ?>
> -------------------------------------
>
> // file.txt
> -------------------------------------
> Some value
> -------------------------------------
>
> If I try and 'use' both files to set a value.
> -------------------------------------
> EXAMPLE A
> <?php
> $value = '';
> include 'file.php';
> echo $value; // 'Some value'
> ?>
> -------------------------------------
>
> -------------------------------------
> EXAMPLE B
> <?php
> $fd = @fopen( 'file.txt', 'rb');
> $contents = '';
> while (!feof($fd)) {
> $contents .= fread($fd, 8192);
> }
> fclose($fd);
> echo $contents; // 'Some value'
> ?>
> -------------------------------------
> Ignoring the fact that Example A is simpler.
>
> Is it true that 'EXAMPLE A' will open the file, (file.php), and assign
> $value only once and then not read the file anymore, (unless it is
> changed).
> I am talking about in the life of the php.exe process, not in the life
> of the script run itself.
>
No, this is not correct. It will be done on every page request.
> Whereas EXAMPLE B will open, read, close the file every single time
> there is a page request.
>
Correct.
> What do you think? Does include open, read, close the file in every
> request? Or will the content of both files be kept for the life of the
> process?
>
> Reagards,
>
> FFMG
>
>
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|