<?php
echo "filename:phptutorial1.php"."<br/>";
echo "1.tutorial:php include and requre"."<br/>";
echo "--------------------------------------------------------------------"."<br/>";
/*file :phptutorial1.php
title :php include and requre
date :03/05/2013
tool :wamp+notepad++
author:chinayaosir
blog :http://blog.csdn.net/chinayaosir
*/
/*
1.PHP include!
语法:include "filename" 或者include_once "filename";
include功能:在执行此PHP文件之前把filename的php源码插入进来!
相当于c/c++的include,java的import源代码码导入功能!
include_once功能:在include功能的基础上,防止php文件代码重复插入的问题
样例:
//登陆网页index.php
include_once 'head.php';
include 'body.php';
include_once 'foot.php'
2.php require
语法:require "filename" 或者require_once "filename";
require功能:在include的功能基础上,添加一个如果代码错误,程序会停止运行!
require_once功能:在require功能基础上,防止php文件代码重复插入的问题!
样例:
//登陆网页index.php
require_once 'head.php';
require 'body.php';
require_once 'foot.php'
//head.php文件代码
<html>
<head>
<title>xxxx retaillink</title>
<style type="text/css">
<!--
#headdiv {
position:absolute;
left:12px;
top:6px;
width:273px;
height:29px;
z-index:1;
}
#logindiv {
position:absolute;
left:9px;
top:52px;
width:277px;
height:96px;
z-index:3;
}
#footdiv {
position:absolute;
left:12px;
top:158px;
width:275px;
height:40px;
z-index:2;
}
-->
</style>
</head>
<body>
<div id="headdiv">
<table width="274" border="1">
<tr>
<th width="264" height="27" scope="col">XXX公司供应链系统</th>
</tr>
</table>
</div>
//body.php文件代码
<form name="loginform" method="post" action="check.php">
<div id="logindiv">
<table width="274" height="85" border="1">
<tr>
<td width="99" height="25" scope="col">usercode</td>
<td width="168" scope="col"><input type="text" name="userid2"> </td>
</tr>
<tr>
<td height="25">password</td>
<td><input type="password" name="pwd2"></td>
</tr>
<tr>
<td height="25"><div align="center"><input name="btreg" type="button" id="btreg" value="register"></div></td>
<td><div align="center"><input name="btlogin" type="button" id="btlogin" value="login"></div></td>
</tr>
</table>
</div>
</form>
//foot.php文件代码
<div id="footdiv">
<table width="274" height="36" border="1">
<tr>
<th scope="col">ABC软件公司制作</th>
</tr>
</table>
</div>
</body>
</html>
<?php
//login.php
require_once "head.php";
include "body.php";
require_once "foot.php";
?>
*/
//login.php
require_once "head.php";
include "body.php";
require_once "foot.php";
?>