Home > Backend Development > PHP Tutorial > The difference between include and require in php

The difference between include and require in php

WBOY
Release: 2016-07-29 09:00:59
Original
944 people have browsed it

The following introduces the difference between include() statement and require() statement in PHP code:

1. Different loading methods and error handling methods

  • include() statement can be placed in the flow control of the program. When the program is executed When it arrives, load the file in. When an error occurs (such as the file does not exist), only a warning will be generated. The require() statement is generally placed at the beginning of the program, and the file will be loaded when the program is executed. When an error occurs (such as the file does not exist), an error will be reported and the script will be terminated.

  • 2.php performance

inlcude() statement will read and evaluate the file every time it is executed.

require() statement performs file processing only once (actually the file content replaces the require() statement.
  • 3.include_once() and require_once()

include_once() includes and Run the file. If the file is already included, it will not be included again.

  • require_once() first checks whether the file has been loaded during script execution. If it has been loaded, it will not be loaded again. For example, a file defines a type. An error will occur if the file is loaded twice

  • ').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i

    ').text(i)); }; $numbering.fadeIn(1700); }); });
The above introduces the difference between include and require in PHP, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template