|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8002 PHP caches files opened with file().
Submitted: 2000-11-28 01:03 UTC Modified: 2000-11-28 06:51 UTC
From: brett_paul at mindspring dot com Assigned:
Status: Closed Package: Directory function related
PHP Version: 4.0.3pl1 OS: Windows 95
Private report: No CVE-ID: None
 [2000-11-28 01:03 UTC] brett_paul at mindspring dot com
I have a page that I am using to edit files on my site. I read the file using file() and show it in a textarea. I save changes to the file. Upon reloading the page, it does not reflect those changes in the newly presented HTML page (even with a hard refresh), but the underlying file was changed successfully (verified this). Seems to be caching file() reads. A call to clearstatcache() does not clear this. Getting an error seems to clear it, however.

Here's the code. $filename is posted from an HTML form:
    if (!isset($filename)) {
        $sLocation = dirname($HTTP_REFERER)."index.html";
    $filename = "c:\\xitami\\webpages\\".$filename;
    echo "<HTML>\n<head><title>Edit file $filename </title></head>\n";
    echo "<body bgcolor=\"eadfdf\" basefont size=4>\n";
    if (!isset($new)) {
        $new = FALSE;
    echo "<form action=\"savefile.php\" method=\"post\">\n";
    if ($new == TRUE) {
        echo "Filename: <input name=\"filename\" length=\"30\"><br>\n";
        $contents = "";
    } else {
        echo "Filename: $filename<input name=\"filename\" type=\"hidden\" value=\"$filename\"><br>\n";
        $contents = file($filename);
        $contents = implode($contents, "");
    $contents = stripcslashes($contents);
    echo "<textarea name=\"contents\" cols=75 rows=20 wrap=\"hard\">$contents</textarea>\n";
    echo "<input type=\"submit\" value=\"save\">\n";
    echo "</form>\n";


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2000-11-28 06:51 UTC]
PHP does not cache results of file(), but your browser
probably caches results of your page. Try to disable caching
in your browser.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Sep 17 20:03:37 2021 UTC