[PHP] Problem with filemtime

2007-07-31 Thread Kevin Murphy
I'm running the following script (simplified for discussion) to  
create a CSV file. My problem here is that the first filemtime and  
the last filemtime always equal each other. What I am trying to get  
is the filemtime ($new_last_modified) of the file that was just  
executed 3 lines earlier. Is there something I need to do  
differently? I tried putting a sleep(20) after the fclose, but that  
didn't seem to help.


$csv_file = myFile.csv;
$last_modified_csv = filemtime($csv_file);

$fh = fopen($csv_file, 'w') or die(can't open file);
fwrite($fh, Data Goes Here);
fclose($fh);

$new_last_modified = filemtime($csv_file);

--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada College
www.wnc.edu
775-445-3326

Re: [PHP] Problem with filemtime

2007-07-31 Thread Stut

Kevin Murphy wrote:
I'm running the following script (simplified for discussion) to create a 
CSV file. My problem here is that the first filemtime and the last 
filemtime always equal each other. What I am trying to get is the 
filemtime ($new_last_modified) of the file that was just executed 3 
lines earlier. Is there something I need to do differently? I tried 
putting a sleep(20) after the fclose, but that didn't seem to help.


$csv_file = myFile.csv;
$last_modified_csv = filemtime($csv_file);

$fh = fopen($csv_file, 'w') or die(can't open file);
fwrite($fh, Data Goes Here);
fclose($fh);

$new_last_modified = filemtime($csv_file);


The data returned by filemtime is cached. Use clearstatcache to clear 
the cache (http://php.net/clearstatcache).


-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Problem with filemtime

2007-07-31 Thread Eddie Dunckley
On Tue 31 Jul 07 22:57, Kevin Murphy wrote:
 $csv_file = myFile.csv;
 $last_modified_csv = filemtime($csv_file);

 $fh = fopen($csv_file, 'w') or die(can't open file);
 fwrite($fh, Data Goes Here);
 fclose($fh);

add a clearstatcache() in here.

(and sometimes just for because you might want to emit a buffer, a 
flush();

 $new_last_modified = filemtime($csv_file);

-- 
Eddie Dunckley - [EMAIL PROTECTED] - Realtime Travel Connections 
IBE Development, www.rttc.co.za, cell 083-379-6891, fax 086-617-7831
Where 33deg53'37.23S 18deg37'57.87E Cape Town Bellville Oakdale ZA
  Honk if you hate peace and quiet.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php