Wednesday, October 19, 2011

What is difference between include() function and require() function?

Both the functions are used to include a PHP file in other PHP file. Generally if we have a block of source code usefull in multiple instances, then we place the block of source code in one file and will include the file in other files. The difference between include() and require() function are as follows:
    (i) If the file path mentioned with the include function is not found then it shows a warning message and continues the execution of the script. Where as require function results a fatal error and stops the execution of the script.
    (ii) The second difference is include function is faster in execution than require function. Because with the require function the parser will check whether the file exists or not. Where as the include function does not bothere about the file is there or not.

No comments:

Post a Comment