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
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: louvetj3 at outlook dot fr
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 15:01:34 2025 UTC