For when using the PHP function require() to include an external php file, as long as the own php file is executed, the content of the external file will be included in the own php file. When the included external When an error occurs in the file, the system will give an error prompt and stop the execution of the php file.
Example:
The program code that calls the file config.inc:
<ol class="dp-xml"> <li class="alt"><span><span class="tag"><span> ?php </span></span></span></li> <li><span>echo "这就是被调用的内容: 您好 ! " ; </span></li> <li class="alt"> <span class="tag">?></span><span> </span> </li> </ol>
The current script example01.php Program code:
<ol class="dp-xml"> <li class="alt"><span><span class="tag"><span> ?php </span></span></span></li> <li><span>echo "代码重用的示例: " ; </span></li> <li class="alt"><span>require ( ' config.inc ' ) ; </span></li> <li><span>//调用另外一个文件config.inc,<br>输出config.inc中的内容 </span></li> <li class="alt"> <span>echo "使用require函数实现的." ; </span><span class="tag">?></span><span> </span> </li> </ol>
Example location: mrsl4example01.php
The result is: Example of code reuse: This is the PHP function require( )The content being called: Hello! Implemented using the require function.