Share the specific usage skills of PHP function require()_PHP tutorial

WBOY
Release: 2016-07-15 13:31:18
Original
944 people have browsed it

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>
Copy after login

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>
Copy after login

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.


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446230.htmlTechArticleWhen 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 It will be included into the own php file. When an error occurs in the included external file...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template