为什么Apache2(Ubuntu)与Apache(windows上的easyPHP服务器)运行不同


Why Apache2 (Ubuntu) run defferent with Apache(easyPHP server on Window)?

我有一个草稿类:(更新

class abb{
   static $fieldSelect;
   function init() {
        self::$field = require_once('inputs/Mapping.php');
   }
   function getField($item) {
        return self::$fieldSelect[$item];
   }
}

和CCD_ 1包含:

<?php
return array(
    ItemType::Food          => 0.7,
    ItemType::Fashion       => 0.5,
);

它在easyPHP(Windows7)上运行良好,但当我将它部署到Apache2(Unbutu)上时,会出现一个错误异常。例如,我输入$item = "Phone"Update here),Apache2在return self::$fieldSelect[$item];行抛出异常:Undefined index: Phone。如果$fieldSelect[$item]不存在,Window上的服务器将返回NULL,但Ubuntu不存在。我只是想看看Window和Ubuntu在运行时的不同

我不明白为什么会这样?

我假设错误报告级别在不同的系统上配置不同。

我看不到$fieldSelect在类中的任何位置声明。也许您应该使用$field

您也在使用$fieldsMapping.php0。

也许这样可以:

class abb{ 
   static $fields; 
   function init() { 
        self::$fields = require_once('inputs/Mapping.php'); 
   } 
   function getField($item) { 
        return self::$fields[$item]; 
   } 
} 

最后,您需要正确地寻址数组键。我不确定你的ItemType是什么定义的。也许使用$item = ItemType::Food访问密钥会有所帮助。