LoginSignup
4
3

More than 5 years have passed since last update.

PHP: file_existsはE_WARNINGを出すことがある

Posted at

PHPのfile_exists関数は、マニュアルによれば失敗したときにE_WARNINGを発生する。

具体的には、open_basedirによってアクセスが許可されていない領域のファイルに対して、file_existsを実行した場合だ。次のコードで再現できる:

error_reporting(-1);

$file = '/tmp/hoge';

touch($file);

ini_set('open_basedir', '/var/www');

var_dump(file_exists($file)); //=> bool(false)

実行結果

Warning: file_exists(): open_basedir restriction in effect. File(/tmp/hoge) is not within the allowed path(s): (/var/www) in

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3