Detailed error on fopen

后端 未结 4 787
深忆病人
深忆病人 2021-01-01 12:13

I\'m using fopen to read from a file

$fh = fopen($path, \'r\') or die(\'Could not open file\');

Now I contantly get error Could not open fi

4条回答
  •  南笙
    南笙 (楼主)
    2021-01-01 12:30

    For php versions prior to 5.2 (lacking error_get_last()) you can use track_errors.

    ini_set('track_errors', 1);
    $fh = fopen('lalala', 'r');
    if ( !$fh ) {
      echo 'fopen failed. reason: ', $php_errormsg;
    }
    

    see also: http://de.php.net/reserved.variables.phperrormsg

提交回复
热议问题