Does it throw fatal error if included file contain

2019-10-18 07:32发布

问题:

Suppose, I'm including a file into my program using include() function.

If the included file is present, path of included file is also specified correctly and the code in included file contains fatal error then will it give a warning or fatal error?

Does the same thing apply to require?

Please don't give me the links from PHP manual as I have already gone through it.

Thanks.

回答1:

Yes.

(PHP 4, PHP 5, PHP 7) The include statement includes and evaluates the specified file.

The documentation below also applies to require. (...)

From http://php.net/manual/en/function.include.php

Making use of include or import will add the content code from the external/separate file to your own file, so the PHP interpreter will check it as a single file and if it contains errors/notices they will be detected.