The following describes how to use the PHP function require. When you use the PHP function require () to include an external PHP file, as long as the PHP file is executed, the content of the external file will be included in the PHP file. When an error occurs to the external fileWhen you use the PHP function require () to include an external PHP file, as long as the PHP file is executed, the content of the external file will be included in the PHP file. When an error occurs for the contained external file, the system will prompt an error and stop executing the php file.
Example:
Code for calling the config. inc file:
- <? Php
- Echo "this is the called content: Hello! ";
- ?>
The program code of the current script example01.php:
- <? Php
- Echo "example of code reuse :";
- Require ('config. Inc ');
- // Call another file config. inc,
Output the content in config. inc.
- Echo "implemented using the require function.";?>
Instance location: mrsl4example01. php
Result: code reuse example: this is the content called by the PHP function require (): Hello! Implemented using the require function.
When using the PHP function require () to include an external PHP file, the content of the external file will be included in the PHP file as long as the PHP file is executed, when an error occurs to the contained external file...