: This article mainly introduces the differences between include and require in PHP. For more information about PHP tutorials, see. The difference between include and require is actually not much different. if the file to be included does not exist, include prompts notice and continues to execute the following statement. require prompts a fatal error and exits.
According to the test, on the win32 Platform, they are all included first and then executed. Therefore, it is recommended that there be no include or require statements in the contained files, which will cause directory confusion.
Maybe * The situation is different in nux and has not been tested yet. If you do not want to include a file multiple times, you can use include_once or require_once # to read and write the file data:
1 function r ($ file_name) {2 $ filenum = @ fopen ($ file_name, "r"); 3 @ flock ($ filenum, LOCK_SH ); 4 $ file_data = @ fread ($ filenum, filesize ($ file_name); 5 @ fclose ($ filenum); 6 return $ file_data; 7} 8 function w ($ file_name, $ data, $ method = "w") {9 $ filenum = @ fopen ($ file_name, $ method); 10 flock ($ filenum, LOCK_EX ); 11 $ file_data = fwrite ($ filenum, $ data); 12 fclose ($ filenum); 13 return $ file_data; 14}
The above introduces the differences between include and require in PHP, including the content, and hope to be helpful to friends who are interested in PHP tutorials.