php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19713 filemtime reports existing file doesn't
Submitted: 2002-10-02 06:55 UTC Modified: 2002-10-02 07:11 UTC
From: eflammer at oddpost dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 4CVS-2002-10-02 OS: Win 2000 Pro
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: eflammer at oddpost dot com
New email:
PHP Version: OS:

 

 [2002-10-02 06:55 UTC] eflammer at oddpost dot com
When using the filemtime() function if i set a var in the script to the file to be tested it works fine, if i read the exat sme data in from an outside file it give a stat warning. Note this happens if i use a relitve or abosulte path.
Below is the code and output to demonstrate:


baseinfo
PHP Version 4.3.0-dev
--------------------------------------------------------------------------------
Test code
--------------------------------------------------------------------------------
 <?php 
print "<HR>baseinfo<BR>"; 
print ("PHP Version ".phpversion()); 
print "<HR>Test code<HR>"; 
show_source(__FILE__); 
print "<HR>Test Case<BR><HR>Using inside var<HR>"; 
$line2 = 'file=./webcam.jpg'; 
list ($id2,$value2) = split("=",$line2); 
$file_2 = $value2; 
print "got setting $value2<BR>";     
print filemtime($file_2); 
print "<HR>Using read in var<HR>"; 
$settings = file("./webstat.ini"); 
$line = $settings[0]; 
list($id,$value) = split("=",$line); 
$file = $value; 
print "got setting $value<BR>"; 
print filemtime($file); 
print "<BR>"; 
?> 

--------------------------------------------------------------------------------
Test Case

--------------------------------------------------------------------------------
Using inside var
--------------------------------------------------------------------------------
got setting ./webcam.jpg
1033559117
--------------------------------------------------------------------------------
Using read in var
--------------------------------------------------------------------------------
got setting ./file.txt 

Warning: filemtime() [function.filemtime]: Stat failed for ./file.txt (errno=2 - No such file or directory) in c:\inetpub\wwwroot\webcam\test_case.php on line 18


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-10-02 06:56 UTC] eflammer at oddpost dot com
fixed typo in my email address
 [2002-10-02 07:11 UTC] hholzgra@php.net
Sorry, but the bug system is not the appropriate forum for asking
support questions. Your problem does not imply a bug in PHP itself.
For a list of more appropriate places to ask for help using PHP,
please visit http://www.php.net/support.php

Thank you for your interest in PHP.

file() doesn't trim of line endings, you have to do that yourself

print filemtime(trim($file))
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 07 23:01:32 2025 UTC