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

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

      1. <legend id='E9Cwm'><style id='E9Cwm'><dir id='E9Cwm'><q id='E9Cwm'></q></dir></style></legend>
          <bdo id='E9Cwm'></bdo><ul id='E9Cwm'></ul>

        当 fopen() 失败时获取有意义的信息 (PHP/suPHP)

        时间:2023-09-21
        <legend id='b0Vrh'><style id='b0Vrh'><dir id='b0Vrh'><q id='b0Vrh'></q></dir></style></legend>

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

                <tbody id='b0Vrh'></tbody>
              • <small id='b0Vrh'></small><noframes id='b0Vrh'>

                <tfoot id='b0Vrh'></tfoot>
                  本文介绍了当 fopen() 失败时获取有意义的信息 (PHP/suPHP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  当我无法打开文件时,如何获得比FALSE"更有意义的信息.

                  How do I get something more meaningful than 'FALSE' when I can't open a file.

                  $myFile = "/home/user/testFile.txt"; 
                  $fh = fopen($myFile, 'w') or die("can't open file");
                  

                  当我使用die语句时,can't open file返回给客户端,几乎没用.如果我删除它,则不会引发任何错误.如果我返回 $fh,它是 FALSE.我尝试了本地文件名和绝对文件名.我的 index.html 文件位于我的hole 文件夹的子文件夹之一中.此外,我将 suPHP 与我试图写入的文件夹一起使用,以获得 0755 的权限(suPHP 要求所有文件夹都使用此权限).

                  When I use the die statement, can't open file is returned to the client, and it is almost useless. If I remove it, no error is raised. If I return $fh it is FALSE. I tried both local file name and absolute file name. My index.html file is in one of the sub folders of my hole folder. Furthermore, I am using suPHP with the folder I am trying to write to having a permission of 0755 (suPHP requires this for all folders).

                  我如何找出出现问题的原因,或者至少在尝试打开文件之前查询它.

                  How do I figure out why there was a problem, or at least query it before trying to open the file.

                  推荐答案

                  fopen 如果失败,应该引发 E_WARNING.请参阅 error_get_last 或 set_error_handler(*) 来捕捉它.除此之外,您可以使用 file_exists 和 is_readable 以检查文件是否丢失或存在其他(可能与权限相关的)问题.

                  fopen should raise an E_WARNING if it fails. See error_get_last or set_error_handler(*) to catch it. Other than that you can use file_exists and is_readable to check whether the file is missing or there's another (probably permission-related) problem.

                  (*) 我认为始终设置一个将所有 PHP 错误转换为异常的错误处理程序是一种很好的做法.

                  (*) I consider it good practice to always set an error handler that turns all PHP errors into exceptions.

                  这篇关于当 fopen() 失败时获取有意义的信息 (PHP/suPHP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:警告 feof() 期望参数 1 是资源 下一篇:PHP 和 Postgres:捕捉错误?

                  相关文章

                  最新文章

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

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

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