我不太懂PHP,但我也不想停止错误报告。
请告诉我一个函数,当没有找到文件时不会显示错误或警告,但在其他方面与include函数相同,例如
<?php include("file.txt"); ?>
您可以在此函数的开头添加@来隐藏警告,例如
<?php @include("file.txt"); ?>
这样,您将不会只看到这行代码的警告。
这个问题应该以一种合理的方式解决,而不是抑制错误和警告。
一个更好的方法是这样做:
$include_file = "file.txt";
if( file_exists($include_file) && is_readable($include_file) ) {
include $include_file;
}