All four have the meaning of including files, but include() and include_once() will continue to execute the program when an error occurs in the included file, while require() and require_once() will not. In addition, include_once() and require_once() only Included once, excess will not be included. example:
$a=5;
//include('./test.php');//The code in test.php is $a =3;
//require('./test.php');
//echo $a;//The result is 8;
//When including the non-existent file test1.php
//include('./test1.php');//The result prompts warning and outputs 5;
//require('./test1.php');//The result prompts a fatal error and stops the program from executing
//echo $a;
include_once('./test.php');
include_once('./test.php');
include_once('./test.php');
include_once('./test.php');
echo $a;
//The result output is 8, because if there are multiple include_once() or require_once(), only the first one will be executed. If there are multiple include() or require(), they will all be executed
http://www.bkjia.com/PHPjc/1072246.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1072246.htmlTechArticleThe difference between include() and require() and include_once() and require_once() in php. All 4 are included The meaning of the file, but include() and include_once() will continue when an error occurs in the included file...
Statement: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