Home >Backend Development >PHP Tutorial >Things to note when introducing php file require
If the PHP statement is placed in an HTML file, it will not be processed. However, if you load this HTML file using the require() statement, any PHP commands within the file will be called. Therefore, include files can be named with any extension, but following a convention, such as naming the extension .inc or .php is a good idea.
If you do not use the .php extension to name it, you need to place the file to be imported outside the document tree to prevent users from viewing the source code in text form after loading it directly in the browser.
If the extension is .php but only contains part of the page or script, an error may occur.
Note: No matter which extension is used, the PHP code in the file to be introduced must be placed between PHP tags. Otherwise, the code will be regarded as text or HTML script and therefore will not be executed.
The above introduces the precautions for introducing the PHP file require, including the content of require and PHP files. I hope it will be helpful to friends who are interested in PHP tutorials.