我的index.php中有include("right.php");
right.php中有include("rightPart.php");我想让index2.php中也有right.php,但是不想让right.php中有rightPart.php
请问代码怎么写?

解决方案 »

  1.   

    index2.php中
    来个
    $file = basename(__FILE__);right.php中来个
    if($file != 'index2.php'){
        //do not include
    }
      

  2.   

    给你绕进去了
    这样的文件结构说明你没设计好
    rightPart.php不要在right.php里include
      

  3.   

    没有想到更好的办法,如果是我肯定把right.php里的include("rightPart.php")去掉然后保存为right2.php!在index2.php中写include("right2.php")。
    期待高手!
      

  4.   

    right.php中有include("rightPart.php");
    rightPart.php和right.php分开写  
    分别导入
      

  5.   


    建议再进行分离,分别进行包含即可,如果实在要这样做,可以使用
    if(你要满足的包含条件)
    {
       include '文件地址';
    }
      

  6.   

    学习了,总结下。
    1、right.php中不定义include("rightPart.php"),在需要的文件分别include().
    2、定义两个right.php  (right1.php,right2.php),一个定义include("rightPart.php"),一个不定义。
    3、3#,7#的方式,加个判断来灵活控制是否定义include("rightPart.php")。有待验证
      

  7.   

    include("rightPart.php");
    的时候做一下判断