I have a draft class:(Update)
class abb{
static $fieldSelect;
function init() {
self::$field = require_once('inputs/Mapping.php');
}
function getField($item) {
return self::$fieldSelect[$item];
}
}
and Mapping.php contain:
<?php
return array(
ItemType::Food => 0.7,
ItemType::Fashion => 0.5,
);
It runs well on easyPHP(windows 7), but when I deploy it onto Apache2(Unbutu), an error exception appears. For example, I input $item = "Phone" (Update here), Apache2 throws exception:Undefined index: Phone at line return self::$fieldSelect[$item]; If $fieldSelect[$item] does not exist, sever on Window will be return NULL but Ubuntu is not. I just wana see the different between Window and Ubuntu when run it.
I don’t understand why it is so?
I don’t see
$fieldSelectdeclared anywhere in your class. Perhaps you should be using$fieldinstead?You are also using
$fieldsand$field.Perhaps this will do:
Finally, you will need to address the array key properly. I am not sure what your
ItemTypeis defined as. Maybe using$item = ItemType::Foodto access the key would help.