超越PHP PHP动态 | 经典文章 | CLASS | 相关下载 | 常见问题 | FORUM | WIKI | 在线手册
Site search:    
<require_once函数>
Last updated: Fri, 22 Jun 2007

include_once()

The include_once() 语句在脚本执行期间包括并运行指定文件。此行为和 include() 语句类似,唯一区别是如果该文件中的代码已经被包括了,则不会再次包括。如同此语句名字暗示的那样,只会包括一次。

include_once() 应该用于在脚本执行期间同一个文件有可能被包括超过一次的情况下,你想确保它只被包括一次以避免函数重定义,变量重新赋值等问题。

使用 require_once()include_once() 的更多例子见最新的 PHP 源程序发行包中的 PEAR 代码。

注: include_once() 是 PHP 4.0.1pl2 中新加入的。

注: 要注意 include_once()require_once() 在大小写不敏感的操作系统中(例如 Windows)的行为可能不是你所期望的。

例子 16-9. include_once() 在 Windows 下不区分大小写

<?php
include_once("a.php"); // this will include a.php
include_once("A.php"); // this will include a.php again on Windows!
?>

警告

Windows 版本的 PHP 在 4.3.0 版之前不支持该函数的远程文件访问,即使 allow_url_fopen 选项已被激活。

参见 include()require()require_once()get_required_files()get_included_files()readfile()virtual()




add a note add a note User Contributed Notes
include_once
shriekingllama at hotmail dot com
08-Dec-2003 06:29
If you use the same case whenever referencing files on a windows system, you will not fun into any problems.
catsdorule at 68kmla dot org
08-Nov-2003 02:10
I'd just like to note, the behavior with windows is the same for all non case sensitive file systems, this includes HFS, HFS+, FAT, FAT32, and NTFS, I am certain that there are more of these non case sensitive file systems, however this would be most apparent to users of Mac OS X.

<require_once函数>
 Last updated: Fri, 22 Jun 2007
view source | feedback | send page | sitemap | aboutus   
Copyright ® 2002-2003 PHPE.NET. All rights reserved
Last updated:2002-11-22