在包含的文件中遇到错误后跳转到下一个包含的文件


Jump to next includedfile after encountering an error in included file

我有一个主PHP文件,其中包括许多独立的文件,它们之间没有关系。

<?php
include_once 'test/test1.php';
include_once 'test/test2.php';
include_once 'test/test3.php';
include_once 'test/test4.php';
include_once 'test/test5.php';
include_once 'test/test6.php';
include_once 'test/test7.php';
?>

但是当我运行这个PHP文件时,我可能会在每个文件中遇到错误。我想知道哪个代码是合适的,如果主文件面临任何错误。它不应该停止工作,而是跳到下一个文件。
我该怎么做呢?

include_once将显示警告并继续执行到下一行,它不会退出。

require_once将抛出错误并退出程序。