About require unconditional inclusion and include conditional inclusion about require unconditional inclusion and include conditional inclusion
// If the variable $ somgthing is true, it will contain the file somefile: 1 if ($ something) {2 include ("somefile "); 3} // regardless of the value of $ something, the following code will include the file somefile into the file: 1 if ($ something) {2 require ("somefile "); 3} // The Interesting example below fully demonstrates the differences between the two functions. 1 $ I = 1; 2 while ($ I <3) {3 require ("somefile. $ I "); 4 $ I ++; 5} // in this code, each loop contains the same file. Obviously, this is not the original intention of the programmer. from the code, we can see that this code will include different files in each loop. To complete this function, you must turn to the include () function: 1 $ I = 1; 2 while ($ I <3) {3 include ("somefile. $ I "); 4 $ I ++; 5}
The above is the content that require unconditionally contains and includes conditions. For more information, see PHP Chinese website (www.php1.cn )!