You are here: include/require cached and fopen is not? « PHP Programming Language « IT news, forums, messages
include/require cached and fopen is not?

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).

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация