i have a script like this :
<html>
<body>
<?php
require("wrongFile.php");
echo "Hello World!";
?>
</body>
</html>
now if wrongfile not exists the two below error will report:
Warning: require(wrongFile.php) [function.require]: failed to open stream: No such file or directory in C:\home\website\test.php on line 5
Fatal error: require() [function.require]:Failed opening required ‘wrongFile.php’ (include_path=’.;C:\php5\pear’) in C:\home\website\test.php on line 5
i know that if not exists file in require() function a fatal error displayed that cause script execution stop but do not understand what is first error
the first error display in using of include() function too
It’s pretty obvious, isn’t it? 🙂
The first warning is thrown from within the
require()function, when it tries to open the file you specified. It can’t open a stream, which is used to read the file, because the file doesn’t exist.Because of that, the function call itself also fails, which explains the ‘Fatal error’.