|
Posted by FFMG on 11/24/07 14:06
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.
Whereas EXAMPLE B will open, read, close the file every single time
there is a page request.
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
--
'webmaster forum' (http://www.httppoint.com) | 'Free Blogs'
(http://www.journalhome.com/) | 'webmaster Directory'
(http://www.webhostshunter.com/)
'Recreation Vehicle insurance'
(http://www.insurance-owl.com/other/car_rec.php) | 'Free URL
redirection service' (http://urlkick.com/)
------------------------------------------------------------------------
FFMG's Profile: http://www.httppoint.com/member.php?userid=580
View this thread: http://www.httppoint.com/showthread.php?t=22555
Message Posted via the webmaster forum http://www.httppoint.com, (Ad revenue sharing).
[Back to original message]
|