php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74081 question about function: file_exists()
Submitted: 2017-02-10 20:28 UTC Modified: 2017-02-11 07:59 UTC
From: louvetj3 at outlook dot fr Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.6.30 OS: WIN10 / WAMP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
42 + 13 = ?
Subscribe to this entry?

 
 [2017-02-10 20:28 UTC] louvetj3 at outlook dot fr
Description:
------------
What is behavior of function file_exists($filename) if a version number is added to filename ie: $filename='myFile.css?ver=09022017'; 
it seems that some times version number is 
taken as part of fileName some times not.


directory: wcommander
file name: myFile.css
see script below

---
From manual page: http://www.php.net/function.file-exists
---


Test script:
---------------
$fileName= 'myFile.css?ver=09022017';
$repertoire = array('wcommander','wmembres','wactualites');
$root = (__DIR__);
$resultat = $fileName;
foreach($repertoire as $key => $value)
{
	if(file_exists($root.'/'.$value.'/'.$fileName))
		$resultat = $value.'/'.$fileName;
}
echo $resultat;



Expected result:
----------------
wcommander/myFile.css?ver=09022017

Actual result:
--------------
it seems that file is found because of version number

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-02-11 07:59 UTC] requinix@php.net
-Status: Open +Status: Not a bug -Type: Documentation Problem +Type: Bug -Package: Website problem +Package: Filesystem function related
 [2017-02-11 07:59 UTC] requinix@php.net
? is only special for URLs. If you're testing normal files then you have to have one actually named "myFile.css?ver=09022017", which is not possible to do on Windows.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 13:01:28 2024 UTC