I have scripts like these:
file_put_contents("filters.php", '<? $filter_arr = '.var_export($filter_arr, true).'; ?>');
include("filters.php");
or:
$xml = '<?xml version="1.0" encoding="UTF-8"?>'."\n<xml>\n\t<items>\n".$xml_0."\n\t</items>\n</xml>";
file_put_contents($PROJECT_ROOT."/xml/$file_type.xml", $xml);
$upload_result = ftp_put($ftp_stream, $destination_file, $PROJECT_ROOT."/xml/$file_type.xml", FTP_BINARY);
Actually changes to those files are applied physically (written to files).
But sometimes not visible after include(), or not sent by ftp_put() to remote server.
It's seems something like PHP caching this files.
Adding sleep(1) before include() doesn't help.
A also have a test like this:
for ($i=1; $i <= 100; $i++) {
echo "$i)";
$filter_arr = array($i);
file_put_contents("test.txt", '<? $filter_arr = '.var_export($filter_arr, true).'; ?>');
include("test.txt");
echo $filter_arr[0]."<br>";
}
About 90% of times output is normal:
1) 1
2) 2
...
100) 100
About 10% of times output is wrong:
1) 1
2) 1
...
100) 1
Playing with flock() or clearstatcache() also have no affect.