+ 5

What is the big difference between include and require statements.

Belal Ahmad

1st Jun 2019, 9:32 AM
Ahmad Belal Mansoori
Ahmad Belal Mansoori - avatar
7 Respostas
+ 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 😀
1st Jun 2019, 1:23 PM
Abdol Hashimi
Abdol Hashimi - avatar
+ 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
1st Jun 2019, 9:52 AM
Prince PS[Not_Active]
Prince PS[Not_Active] - avatar
+ 7
If I remember right this information is present in the PHP tutorial.
3rd Jun 2019, 4:07 AM
Sonic
Sonic - avatar
+ 3
Thanks👍
1st Jun 2019, 1:07 PM
Ahmad Belal Mansoori
Ahmad Belal Mansoori - avatar
+ 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
23rd Jun 2019, 5:23 AM
Titus M Dishon
Titus M Dishon - avatar
+ 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.
5th Jun 2019, 9:11 AM
Richard Twum
Richard Twum - avatar
+ 1
❤❤
23rd Jun 2019, 7:00 PM
Ahmad Belal Mansoori
Ahmad Belal Mansoori - avatar