search
Homephp教程php手册分享PHP函数require()的具体使用技巧

分享PHP函数require()的具体使用技巧

Jun 13, 2016 am 11:08 AM
phprequireuseskillsspecificfunctionshareIncludeexternalof

对于使用PHP函数require()包含外部php文件时,只要自身php文件被执行,外部文件的内容就将被包含进该自身php文件,当包含的外部文件发生错误时,系统将给出错误提示,并且停止php文件的执行。

示例:

调用文件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>

当前脚本example01.php的程序代码:

<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>

实例位置:mrsl4example01.php

结果为:代码重用的示例:这就是PHP函数require()被调用的内容:您好!使用require函数实现的。


Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use