How to include only if file exists

前端 未结 10 856
深忆病人
深忆病人 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:29

    @include($file);
    

    Using at in front, ignores any error that that function might generate. Do not abuse this as IT IS WAY SLOWER than checking with if, but it is the shortest code alternative.

提交回复
热议问题