3.1.3.php.htm

来自「php5的最新帮助文档」· HTM 代码 · 共 43 行

HTM
43
字号
<html>
<head>
<meta content="text/html; charset=gb2312" http-equiv=Content-Type>
<title>引用文件</title>
<style type="text/css">
  a {text-decoration: none;color:#6666ff;}
  a:hover {color:#ff0000;}
</style>
</head>
<body bgcolor=ffffff leftmargin=0 topmargin=0 marginheight=0 marginwidth=0>
 
<div align=center><table border=0 width=70%><tr>
<td valign=middle width=20><hr size=1 width=100%></td>
<td valign=middle nowrap><font color=e06060 size=+2><b>引用文件</b></font></td>
<td valign=middle width=100%><hr size=1 width=100%></td>
</tr></table></div><p>
<div align=center><table border=0 width=70%><tr><td>

PHP 最吸引人的特色之一大概就是它的引用文件了。用这个方法可以将常用的功能写成一个函数,放在文件之中,然后引用之后就可以调用这个函数了。<p>

引用文件的方法有两种:require 及 include。两种方式提供不同的使用弹性。<p>

require 的使用方法如 <code>require("MyRequireFile.php");</code> 。这个函数通常放在 PHP 程序的最前面,PHP 程序在执行前,就会先读入 require 所指定引入的文件,使它变成 PHP 程序网页的一部份。常用的函数,亦可以这个方法将它引入网页中。<p>

include 使用方法如 <code>include("MyIncludeFile.php");</code> 。这个函数一般是放在流程控制的处理部分中。PHP 程序网页在读到 include 的文件时,才将它读进来。这种方式,可以把程序执行时的流程简单化。
        <p> 在 PHP 的<a href="http://www.php.net/" tppabs="http://www.php.net/">官方网站</a>中,每页都可以看到原始程序,更是处处看到这两种引入文件的方法。 
        <p><hr size=1><br>如果你对此手册有任何问题,请到下面网址提问:&nbsp;<a href="www.web745.com">WEB开发知识库</a>&nbsp;(<a href="http://www.web745.com">www.web745.com</a>)<p>
</td></tr></table></div>
<p>
<div align=center>
  <table border=0>
    <tr>
      <td>[ <a href="3.1.2.php.htm" alt="3.1.2.php">上一页</a> 
      </td>
      <td> <a href="3.1.4.php.htm" alt="3.1.4.php">下一页</a> 
        ]</td>
    </tr>
  </table>
</div><p><br><br>

</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?