file_exists 与 realpath 返回 false ,但文件存在,权限正常

WBOY
Libérer: 2016-06-06 20:44:06
original
1833 Les gens l'ont consulté

下文中的问题,在 PHP 5.5.14 中发生的,
测试了之后,在 5.4.30 后并无此问题……
不知道是 5.5.14 的 Bug 还是神马的……
在 5.5.14 中是否有办法解决?


(注:文中文件夹名称已打码)
在 PHP 当中实测代码如下:

<code class="lang-php"><?php var_dump(realpath('./'));
var_dump(realpath('../'));
var_dump(realpath('../u******/api/uc.php'));

</code></code>
Copier après la connexion
Copier après la connexion

得到了结果如下:

<code>string(28) "/home/wwwroot/m*****/u******"  
bool(false)  
bool(false)  
</code>
Copier après la connexion
Copier après la connexion

在网上找了好久,起初认为是文件夹权限,
所以我将 /home/wwwroot/ 下归递改为 755 (chmod -Rf 755 /home/wwwroot),
但是结果还是一样。

回复内容:

下文中的问题,在 PHP 5.5.14 中发生的,
测试了之后,在 5.4.30 后并无此问题……
不知道是 5.5.14 的 Bug 还是神马的……
在 5.5.14 中是否有办法解决?


(注:文中文件夹名称已打码)
在 PHP 当中实测代码如下:

<code class="lang-php"><?php var_dump(realpath('./'));
var_dump(realpath('../'));
var_dump(realpath('../u******/api/uc.php'));

</code></code>
Copier après la connexion
Copier après la connexion

得到了结果如下:

<code>string(28) "/home/wwwroot/m*****/u******"  
bool(false)  
bool(false)  
</code>
Copier après la connexion
Copier après la connexion

在网上找了好久,起初认为是文件夹权限,
所以我将 /home/wwwroot/ 下归递改为 755 (chmod -Rf 755 /home/wwwroot),
但是结果还是一样。

如果是Redhat系的系统,还要检查SELinux的权限是否正确

php文件是不是utf8编码,要检测的文件名是不是中文?如果是这样,需要转码为gb2312,
例:

<code class="lang-php">file_exists(iconv('utf-8','gbk','D:/test/中文啊.txt'));
</code>
Copier après la connexion
Étiquettes associées:
php
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!