array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.require-once.php', 1 => 'require_once', ), 'up' => array ( 0 => 'language.control-structures.php', 1 => '流程控制', ), 'prev' => array ( 0 => 'function.include.php', 1 => 'include', ), 'next' => array ( 0 => 'function.include-once.php', 1 => 'include_once', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'language/control-structures/require-once.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4, PHP 5, PHP 7, PHP 8)
require_once
表达式和 require
表达式完全相同,唯一区别是 PHP 会检查该文件是否已经被包含过,如果是则不会再次包含。
参见 include_once 的文档来理解
_once
的含义,并理解与没有 _once
时候有什么不同。