因为c中没有包含a呀!!
刚才你说的里面,只有b包含了a!
用session,cookies都可以!!

解决方案 »

  1.   

    但是在b中包含了c,而且是在a文件之后,我在浏览器中调用的是b文件,所以可以不用在c中包含a呀。
      

  2.   

    To唠叨:
    我在a中定义了我要用的变量,而且针对现在的问题如果我在c文件中包含a,那么就不会出现未定义的错误了。
      

  3.   

    a文件:
    <?php

    class GlobleVarias{

    //the following variables is defined and used for globles .

    //for the different kinds of versions,you also can make two system database ,by using this variable to divid. 
    var $Version = "demo";
    //the URL address
    var $Url = "";
    //the URL VARIABLES LIST
    var $UrlVariaList = "";
    //Application CD
    var $AppCd = "";
    //fuse code
    var $FuseCode = "";
    //application directory
    var $AppRootDir = ""; function setGlbFuseCode($str){
    $GLOBALS["DOU_FuseCode"] = $str;
    }

    function setGlbAppRootDir(){
    $temp = explode("?",$_SERVER['REQUEST_URI']);
    $temp = explode("/",$temp[0]);
    for($i=0;$i<sizeof($temp)-1;$i++){
    $this->AppRootDir = $this->AppRootDir.$temp[$i];
    }

    $temp = explode("/",$_SERVER['SERVER_PROTOCOL']);
    $tempStr = $tempStr.$temp[0]."://";
    $tempStr = $tempStr.$_SERVER['SERVER_NAME'] ;
    if($_SERVER['SERVER_PORT'] != "80"){
    $tempStr = $tempStr.":".$_SERVER['SERVER_PORT'];
    }

    $GLOBALS["DOU_AppRootDir"] = strtolower($tempStr)."/".$this->AppRootDir."/app/";
    $GLOBALS["DOU_SysRootDir"] = strtolower($tempStr)."/".$this->AppRootDir."/" ;
    }

    }



    //This method is used to rederict to the page which you want 

    function redirect($pageURL){
    echo "<SCRIPT language=\"JAVASCRIPT\">";
    echo "location.href=\"".$pageURL."\"";
    echo "</SCRIPT>";
    }

    //this class is specially for the access of the different kind of database .
    class DBAccess{
    //here will start to define the variables and some are const .

    //the name of the DB server
    var $hostName = "LocalHost";
    //the DB server's access port
    var $port = "3306";
    //the user of the database
    var $userName = "root";
    //the password of the DB user
    var $passWord = "admin";
    //The name of the database
    var $databaseName = "temp";
    /****
    the type of the database,the values as the follows:
    1.[MYSQL] -> mysql database
    2.[MSSQL] -> microsoft sql server database
    //3.[ORACLE] -> oracle database
    //4.[ACCESS] ->  microsoft access database

    the default value is the mysql database.
    *****/
    var $DBType = "MYSQL";

    //the operation of the variable 'hostName'
    function setHostName($strName){
    $this->hostName = $strName;
    }

    function getHostName(){
    return $this->hostName;
    }

    //the operation of the variable 'port'
    function setPort($strPort){
    $this->port = $strPort;
    }

    function getPort(){
    return $this->port;
    }

    //the operation of the variable 'userName'
    function setUserName($strUserName){
    $this->userName = $strUserName;
    }

    function getUserName(){
    return $this->userName;
    }

    //the operation of the variable 'passWord'
    function setPassWord($strPassWord){
    $this->passWord = $strPassWord;
    }

    function getPassWord(){
    return $this->passWord;
    }

    //the operation of the variable 'DBType'
    function setDBType($dbType){
    $this->DBType = $dbType;
    }

    function getDBType(){
    return $this->DBType;
    }

    //the set varaibles function 
    function setVariables($hostName,$userName,$passWord,$databaseName,$hostPort="3306",$dbType="MYSQL"){
    $this->setHostName($hostName);
    $this->setUserName($userName);
    $this->setPassWord($passWord);
    $this->setPort($hostPort);
    $this->setDBType($dbType);
    $this->databaseName = $databaseName;
    }
    //the database connection function .
    //NOTE: You must set the variables such as the hostName,the port,the userName,the password
    //before you use this method,you can complete it by use function 'setVariables()'
    /****
    the type of the database's values as the follows:
    1.[MYSQL] -> mysql database
    2.[MSSQL] -> microsoft sql server database
    //3.[ORACLE] -> oracle database
    //4.[ACCESS] ->  microsoft access database

    the default value is the mysql database.
    *****/
    function DBConn(){

    switch($this->DBType){
    case "MYSQL" : 
    mysql_connect($this->hostName,$this->userName,$this->passWord);
    break;
    case "MSSQL" :
    mssql_connect($this->hostName,$this->userName,$this->passWord);
    break;
    default :
    echo "The database type [".$this->DBType."]is not right ! Please set it by using the function of [setDBType()].";
    break;
    }

    }
    /***
    function query($str){
    var $resultSet=;
    switch($this->DBType){
    case "MYSQL" :
    mysql_select_db($this->databaseName);
    $resultSet = mysql_query($str);
    break;
    case "MSSQL" :
    //mssql_select_db($this->databaseName);
    echo "Sorry ! MSSQL DB is not support now";
    break;
    }
    return $resultSet;
    }
    ****/

    }

    ?>
      

  4.   

    b文件:<?php
    require("Application.php");

    $temp = new GlobleVarias();

    $temp->setGlbFuseCode("ind_input");
    $temp->setGlbAppRootDir();
    $fuseCodeArray = explode("_",$DOU_FuseCode);

    switch($fuseCodeArray[0]){

    case "ind" :
    include($DOU_AppRootDir."input.php");
    break;
    default :
    include("error.php");
    break;
    }

    ?>
      

  5.   

    c文件:
    <?php
    $dbObj = new DBAccess();


    ?>
      

  6.   

    抱歉 b文件中的 include($DOU_AppRootDir.  "input.php  ");  中的input.php 就是c文件
      

  7.   

    我确信,因为一旦在c文件中加入require("a文件"),程序就按照所期望的结果运行了
      

  8.   

    报告错误的原因会不会是编译时的错误,也就是说对c文件单独编译,因为没有在c中包含a 而出错?我们现在考虑的都是运行期间应该行的通的做法。
      

  9.   

    按照书上说的require的处理机制应该可吧?
    我也遇到过,郁闷死了~O~