---- ini.php ----
$arr = array("1" => "春", "2" => "夏", "3" => "秋", "4" => "冬");---- sub.php ---- 
require_once("ini.php");
class MyDB {
  print_r($arr);  //此处出错!该如何引用$arr?
}

解决方案 »

  1.   

    print_r($GLOBALS['arr']); 
    queryphp 简单 MVC ORM数据库类框架 
    ---------------------------------------------
    http://topic.csdn.net/u/20100310/11/62a60067-b3da-4dee-9d6a-f1baeb2f3f33.html
      

  2.   

    class MyDB {
     function MyDB (){
    gloabl $arr;
    print_r($arr);
    }
    }
      

  3.   

    在变得前加 gloabl 表示全局
      

  4.   

    在变量前加 gloabl,解决不了。 $GLOBALS['arr'] OK