Php 为什么';t file_存在()工作吗?

Php 为什么';t file_存在()工作吗?,php,quotes,file-exists,Php,Quotes,File Exists,以下是我的PHP代码: [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) 看来确实是报价问题: <?php

以下是我的PHP代码:

[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)
看来确实是报价问题:

<?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]# 

让它在bash中工作

请尝试删除双引号,因为它已经用单引号引用。

请查看手册以了解更多信息

请注意本节:

“对于由于安全模式限制而无法访问的文件,此函数返回FALSE。但是,如果这些文件位于安全模式\u include\u dir,则仍然可以包含这些文件。”


我猜您使用的是我需要运行exec(),它运行bash命令,任何一方都将无法以这种方式工作。请在不同位置的不同文件上尝试file_exists(),以查看它是否工作。如果它真的有效,那么你的问题是无法接近。如果它不起作用,那么问题在于命令,我们可以从那里着手。让我知道,很好。您的问题现在解决了吗,或者您在使用exec()时遇到问题了吗?太好了。如果您还有任何问题,请在此发布。可能是
<?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]# 
preg_replace('/\/([^\/\s]+\s+[^\/]+)(?:\/|$)/','/"${1}"/',$file);