2

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

2
  • You can also turn off warnings all together, stackoverflow.com/questions/1645661/… Commented Nov 7, 2011 at 15:57
  • 1
    @everyone: do not format error messages as a code. you're making them worse than just plain text. Commented Nov 7, 2011 at 16:18

2 Answers 2

6

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'.

Sign up to request clarification or add additional context in comments.

Comments

0

The first is warning, not error. You can try using @include to suppress it. (naturally, it's of no great use with require).

1 Comment

why, why this answer was ever upvoted? What can be even a slightest reason?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.