+ 5
What is the big difference between include and require statements.
Belal Ahmad
7 Antworten
+ 6
When you use another php script into your php file when you insert that as required() it gives you error and you php engine stops interpreting remaining parts of your code if it couldn't use that file for any reasons (file doesn't exists or ...)
But when you use that as include() php doesn't gives you error and php engine runs remained parts of your code.
Plz if you liked my answer tick that right side tick mark 😀
+ 13
The require() function is identical to include(), except that it handles errors differently. If an error occurs, the include() function generates a warning, but the script will continue execution. The require() generates a fatal error, and the script will stop.
More information :
https://stackoverflow.com/questions/2418473/difference-between-require-include-require-once-and-include-once
https://andy-carter.com/blog/difference-between-include-and-require-statements-in-php
Thanks
+ 7
If I remember right this information is present in the PHP tutorial.
+ 3
Thanks👍
+ 3
When you have your footer.php, header.php, and maibody.php, to use the header in your mainbody, just include them, the header at the top and footer at the file end. When you have a dB connection.php that connects to the dB, require it at the file beginning to reuse the connection
+ 1
Php scripts can still run if the 'include' file is not but found.. BUT 'require' files are mandatory, if not found error echo's and script stops.
+ 1
❤❤