How to include only if file exists

前端 未结 10 857
深忆病人
深忆病人 2020-12-28 12:24

I need an include function / statement that will include a file only if it exists. Is there one in PHP?

You might suggest using @include bu

10条回答
  •  南笙
    南笙 (楼主)
    2020-12-28 12:36

    the @ suppresses error messages.

    you cloud use:

    $file = 'script.php';
    if(file_exists($file))
      include($file);
    

提交回复
热议问题