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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 02:01:29 2024 UTC