include和require函数可以在一个php文件中插入另一个php文件的内容,
两者不同之处在于对文件错误的处理上,include产生的的警告,而require产生的是错误。当一个函数经常被不同页面调用、或者创建页眉、页脚等元素时,经常用到include和require函数。
如:date.php如下:
<html>
<body>
<?php
echo date("Y/m/d") . " ";
?>
</body>
</html>
show.php如下:
<html>
<body>
<?php include ("date.php"); ?> //或者require
helloworld!!!
</body>
</html>
这样就在show.php中添加了date.php中的内容。