Voici mon code PHP:Pourquoi file_exists() ne fonctionne-t-il pas?
[[email protected] htdocs]# vi test.php
<?php
var_dump(file_exists('/usr/local/apache2/resumes/28/"Chapel Hill"/franky_li/"CV.doc"'));
?>
"test.php" [New] 5L, 100C written
[[email protected] htdocs]# php test.php
bool(false)
qui dit que le fichier n'existe pas, mais en fait, il fait:
[[email protected] htdocs]# ls -l /usr/local/apache2/resumes/28/"Chapel Hill"/franky_li/"CV.doc"
-rw-r--r-- 1 daemon root 36864 Oct 17 2008 /usr/local/apache2/resumes/28/Chapel Hill/franky_li/CV.doc
[[email protected] htdocs]#
semble qu'il est en effet question de citation:
<?php
var_dump(file_exists('/usr/local/apache2/resumes/28/Chapel Hill/franky_li/CV.doc'));
?>
~
~
"test.php" 5L, 96C written
[[email protected] htdocs]# php test.php
bool(true)
[[email protected] htdocs]#
Fixé maintenant en utilisant le convertisseur suivant:
preg_replace('/\/([^\/\s]+\s+[^\/]+)(?:\/|$)/','/"${1}"/',$file);
pour le faire fonctionner dans bash!
duplication possible de [PHP's file_exists() ne fonctionnera pas pour moi?] (Http://stackoverflow.com/questions/1287837/phps-file-exists-will-not-work-for-me) – razlebe