+ 6
require_once(), require(), include().What is difference between them?
(PHP)
5 Antworten
+ 6
All functions can be used to include a php file in another one.
The use of Require will generate an error if the file not found while Include() doesn't .
Require_once() If it is found that the file has already been included, calling script is going to ignore further inclusions.
+ 6
You know the answer already to provide it yourself.
+ 5
require() includes and evaluates a specific file, while require_once() does
that only if it has not been included before (on the same page). So,
require_once() is recommended to use when you want to include a file
where you have a lot of functions for example. This way you make sure you
don’t include the file more times and you will not get the “function re-
declared” error.
+ 3
But u r not quite right.....
+ 2
required():when use this function while if file is not found then its give to error so it is required for code.
required_once():If we call one file two or more times then its call only once so,this is ignore other calls for same files.
include(): If file is present then its included in to code or not then not generate error.So when file's code is not important for code while we can use this function.