1.include("path")

 
  
  1. <?php 
  2.    //直接包含 
  3.    include "path"
  4.    //若用IF条件来判断是否要包含文件进,要用大括号; 
  5.    if (true){ 
  6.          include (""); 
  7.     }else { 
  8.          include (""); 
  9.     } 
  10. ?> 

返回值测试; 正常情况下是包含了为1 否则为0;但小弟测试后发现

a.当包含的php非空文件时,会执行里面相应的代码+1;如果包含失败;返回错误提示;

b.当包含的文件有return 时,返回return 内容 ;

 
  
  1. <?php 
  2.   //test1.php 
  3.    return  "1111"
  4. ?> 
 
  
  1. <?php 
  2.   //test2.php 
  3.   $ret =  include ("test1.php"); 
  4.   echo $ret;  
  5. ?> 

结果为 1111 ; 这里只试这个,其他的自己试下吧;我是用easyeclipse for php

2.include_once

  确保只包含一次文件;只有一次。 其他与include相同

 

 

3.请求文件

reuqire (path) //

a无论require()位置在哪里,指定文件都会包含到出来require()的脚本中,即使require为假 ;

brequire()出错时,脚 本将停止执行。但incude()会继续执行。

 

4.require_once();只请求文件一次。即只有一次。