include() 函数
来源:互联网 发布:淘宝商城出售 编辑:程序博客网 时间:2024/05/30 05:13
include() 函数
include() 函数可获得指定文件中的所有文本,并把文本拷贝到使用 include 函数的文件中。
例子 1
假设您拥有一个标准的页眉文件,名为 "header.php"。如需在页面中引用这个页眉文件,请使用 include() 函数,就像这样:
<html><body><?php include("header.php"); ?>
<h1>Welcome to my home page</h1><p>Some text</p></body></html>
例子 2
现在,假设我们有一个在所有页面上使用的标准菜单文件。请看下面这个 "menu.php":
<html><body><a href="http://www.w3school.com.cn/default.php">Home</a> |<a href="http://www.w3school.com.cn/about.php">About Us</a> | <a href="http://www.w3school.com.cn/contact.php">Contact Us</a>
三个文件,"default.php"、"about.php" 以及 "contact.php" 都引用了 "menu.php" 文件。这是 "default.php" 中的代码:
<?php include("menu.php"); ?>
<h1>Welcome to my home page</h1><p>Some text</p></body></html>
如果您在浏览器中查看 "default.php" 的源代码,应该类似这样:
<html><body><a href="default.php">Home</a> |<a href="about.php">About Us</a> | <a href="contact.php">Contact Us</a><h1>Welcome to my home page</h1><p>Some text</p></body></html>
同时,当然,我们也将用相同的方法处理 "about.php" 和 "contact.php"。通过使用引用文件,在您需要重命名链接、更改链接顺序或向站点添加另一张网页时,只要简单地更新 "menu.php" 文件中的文本即可。
- include() 函数
- JS版include函数
- #include <cctype>的函数
- #include <algorithm> 常用函数
- #include <algorithm> 常用函数
- #include <algorithm> 常用函数
- #include <algorithm> 常用函数
- #include <algorithm> 常用函数
- #include <algorithm> 常用函数
- #include <algorithm> 常用函数
- #include <algorithm> 常用函数
- #include <algorithm> 常用函数
- #include <algorithm> 常用函数
- #include <algorithm> 常用函数
- smarty-内建函数(include)
- #include<algorithm>里的函数
- #include<algorithm>里的函数
- #include<algorithm>里的函数
- 调用XMLHTTP
- 用阳光心态面对生活
- PHP $_GET
- GPU & CUDA
- PHP $_POST
- include() 函数
- require() 函数
- PHP中post与get的区别
- GUN-ld 链接脚本浅析
- PHP Cookies
- PHP Sessions
- PHP 错误处理
- PHP 过滤器(Filter)
- MDA常见问题解答