Here is my PHP code:
[root@file 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
[root@file htdocs]# php test.php
bool(false)
which says the file doesn't exists,but in fact it does:
[root@file 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
[root@file htdocs]#
seems it's indeed quote issue:
<?php
var_dump(file_exists('/usr/local/apache2/resumes/28/Chapel Hill/franky_li/CV.doc'));
?>
~
~
"test.php" 5L, 96C written
[root@file htdocs]# php test.php
bool(true)
[root@file htdocs]#
fixed now by using the following converter:
preg_replace('/\/([^\/\s]+\s+[^\/]+)(?:\/|$)/','/"${1}"/',$file);
to make it work in bash!
尝试删除双引号,因为双引号已被单引号引起来。
Check the manual for file_exists .
Note this section:
"This function returns FALSE for files inaccessible due to safe mode restrictions. However these files still can be included if they are located in safe_mode_include_dir."
My guess is that you're using <PHP 6.0.0, and you have safe_mode on (it is by default, and is on most hosts). If this is the case, you won't find the file unless it's included in safe_mode_include_dir.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.