PHP 提供了 6 种包含函数:include()、include_once()、require()、require_once()、file_get_contents() 和 __autoload()。它们的区别在于文件包含方式,以及对变量的作用域的影响。
PHP 包含函数详解
PHP 提供了多种包含函数,用于在 PHP 脚本中包含外部文件。它们的主要区别在于文件包含的方式和对变量的作用域。
1. include()
include("filename.php");
2. include_once()
立即学习“PHP免费学习笔记(深入)”;
include_once("filename.php");
3. require()
require("filename.php");
4. require_once()
require_once("filename.php");
5. file_get_contents()
$contents = file_get_contents("filename.php"); eval($contents);
6. __autoload() 函数
function __autoload($classname) { require("class.$classname.php"); }
以上就是php包含函数有哪些的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号