<tfoot id='jTpIn'></tfoot>
    • <bdo id='jTpIn'></bdo><ul id='jTpIn'></ul>
      <legend id='jTpIn'><style id='jTpIn'><dir id='jTpIn'><q id='jTpIn'></q></dir></style></legend>

        <small id='jTpIn'></small><noframes id='jTpIn'>

        <i id='jTpIn'><tr id='jTpIn'><dt id='jTpIn'><q id='jTpIn'><span id='jTpIn'><b id='jTpIn'><form id='jTpIn'><ins id='jTpIn'></ins><ul id='jTpIn'></ul><sub id='jTpIn'></sub></form><legend id='jTpIn'></legend><bdo id='jTpIn'><pre id='jTpIn'><center id='jTpIn'></center></pre></bdo></b><th id='jTpIn'></th></span></q></dt></tr></i><div id='jTpIn'><tfoot id='jTpIn'></tfoot><dl id='jTpIn'><fieldset id='jTpIn'></fieldset></dl></div>

        PHP:如何检查文件是否不存在或权限是否被拒绝?

        PHP: How to check if file not exists or permission is denied?(PHP:如何检查文件是否不存在或权限是否被拒绝?)
      1. <i id='E0gOi'><tr id='E0gOi'><dt id='E0gOi'><q id='E0gOi'><span id='E0gOi'><b id='E0gOi'><form id='E0gOi'><ins id='E0gOi'></ins><ul id='E0gOi'></ul><sub id='E0gOi'></sub></form><legend id='E0gOi'></legend><bdo id='E0gOi'><pre id='E0gOi'><center id='E0gOi'></center></pre></bdo></b><th id='E0gOi'></th></span></q></dt></tr></i><div id='E0gOi'><tfoot id='E0gOi'></tfoot><dl id='E0gOi'><fieldset id='E0gOi'></fieldset></dl></div>

        <legend id='E0gOi'><style id='E0gOi'><dir id='E0gOi'><q id='E0gOi'></q></dir></style></legend>

        <small id='E0gOi'></small><noframes id='E0gOi'>

              <tfoot id='E0gOi'></tfoot>

                <bdo id='E0gOi'></bdo><ul id='E0gOi'></ul>
                    <tbody id='E0gOi'></tbody>
                • 本文介绍了PHP:如何检查文件是否不存在或权限是否被拒绝?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想检查文件是否不存在.当 file_exists() 函数返回 false 时,我无法确定该文件是否不存在或我没有该文件的权限.

                  I want to check if file do not exists. When file_exists() function returns false I can't be sure if the file do not exist or I don't have permission to the file.

                  如何辨别这两种可能性?

                  How to discern that two possibilities?

                  推荐答案

                  我编写了检查文件是否存在的函数.如果文件系统中没有这样的文件,则返回false,否则返回true.我的函数检查(自下而上)目录结构.应该相当确定 $root 目录存在.

                  I wrote function which check if file can exists. It return false if there is no such file in filesystem, otherwise it returns true. My function checks (bottom-up) directory structure. One should be fairly sure that $root directory exists.

                  private function fileCanExists($root, $path) {
                      $root .= '/';
                      if (file_exists($root . $path))
                          return true;
                      while ($path != '.') {
                          $path = dirname($path);
                          if (file_exists($root . $path)) {
                              if (is_readable($root . $path))
                                  return false;
                              else
                                  return true;
                          }
                      }
                      return false;
                  }
                  

                  这就是我写的意思:

                  我想检查文件是否不存在.

                  I want to check if file do not exists.

                  这篇关于PHP:如何检查文件是否不存在或权限是否被拒绝?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Appending GET parameters to URL from lt;formgt; action(将 GET 参数附加到来自 lt;formgt; 的 URL行动)
                  Forcing quot;Save Asquot; dialog via jQuery GET(强制“另存为通过 jQuery GET 对话框)
                  PHP - get certain word from string(PHP - 从字符串中获取某个单词)
                  How to debug a get request in php using curl(如何使用 curl 在 php 中调试 get 请求)
                  get a # from a url in php(从 php 中的 url 获取 #)
                  PHP - include() file not working when variables are put in url?(PHP - 将变量放入 url 时,include() 文件不起作用?)
                  • <bdo id='MCC9a'></bdo><ul id='MCC9a'></ul>
                  • <legend id='MCC9a'><style id='MCC9a'><dir id='MCC9a'><q id='MCC9a'></q></dir></style></legend>

                      <small id='MCC9a'></small><noframes id='MCC9a'>

                            <tbody id='MCC9a'></tbody>
                          • <i id='MCC9a'><tr id='MCC9a'><dt id='MCC9a'><q id='MCC9a'><span id='MCC9a'><b id='MCC9a'><form id='MCC9a'><ins id='MCC9a'></ins><ul id='MCC9a'></ul><sub id='MCC9a'></sub></form><legend id='MCC9a'></legend><bdo id='MCC9a'><pre id='MCC9a'><center id='MCC9a'></center></pre></bdo></b><th id='MCC9a'></th></span></q></dt></tr></i><div id='MCC9a'><tfoot id='MCC9a'></tfoot><dl id='MCC9a'><fieldset id='MCC9a'></fieldset></dl></div>
                          • <tfoot id='MCC9a'></tfoot>