Could you please tell me which one (include or require once) is it better to use. As I have read require_once is preffered as it stops the execution after an error. It depends of what you want to include, right? Also using include and require makes the code to be more effective? As I can understand the incude and require just make the code more clear(helping to avoid repeating parts of code), effectiveness is not achieved as the same code is added in each file. Finally, I have some javascript code in each of my files(different javascript code in each file) Is it a good idea to put all the javascript code from all of my pages into one file and just include this file in each page? Thank you in advance!
Share
For your JS questions, do separate questions.
It’s simple for me:
include_once
Only use if your script will continue without the included script, without errors or odd behaviors (rare).
require_once
Use if your script needs the required file, such as database connection details or anything of the sort.
If your error_level is set appropriately this shouldn’t pose a problem/issue.