|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2000-11-28 06:51 UTC] stas@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 06:00:02 2025 UTC |
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"; header("location:$sLocation"); } $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"; clearstatcache(); $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"; ?> </body> </html>