I went to interview a php developer yesterday and saw a question on the test paper: What is the difference between include and require? This question can be a required question in the php Development Interview. There are also various answers and explanations on the Internet. But I really couldn't remember it. Now let's look back at this question.
I went to interview a php developer yesterday and saw a question on the test paper:
What is the difference between include and require?
This question can be a required question in the php Development Interview. There are also various answers and explanations on the Internet. But I really couldn't remember it.
Now I have a new understanding of this problem:
As an excellent open-source program, PHP provides functions that will express the function as much as possible. It is much easier to understand the differences between the two functions.
Require is required. If this statement is used, that is, to tell the PHP kernel that the program needs this file depends on this file. Or in other words: I want her! Therefore, if PHP finds that the file in the require parameter does not exist, it will report fatal error and stop executing the following statement.
Include is included. If this statement is used, it tells the PHP kernel that the file is included during program execution. To put it bluntly, bring her here! If PHP cannot find her, it will only prompt that she cannot be found and cannot be taken with her. Instead of stopping the execution of the following script, because we did not tell the PHP kernel that the following program depends on this sub-file.