data = array(); } public function setItem($key, $item){ $worked = false; if ($this->data[$key] = $item){ $worked = true;} return $worked; } public function setDataArray($userData){ // sometimes it's easiest to set the whole data array in one go // it's important though that $userData is actually an array $this->data = (array)$userData; } public function getItemByKey($key){ $value = null; if (array_key_exists($key,$this->data)){ $value = $this->data[$key]; } return $value; } public function getItemsByValue($value, $strict){ // $strict = true, means do a strict '===' comparison $keys = array_keys($this->data, $value, $strict); return $keys; } public function getDataArray(){ // sometimes it's easiest just to get the whole data array return $this->data; } public function getDataArrayWithErrors(){ // sometimes you want the whole array plus errors $dataWithErrors = $this->data; if (isset($GLOBALS['ALL_ERRORS'])){ $dataWithErrors['ALL_ERRORS'] = $GLOBALS['ALL_ERRORS']; } else{ $dataWithErrors['ALL_ERRORS'] = array(); } return $dataWithErrors; } public function send(){ // exits script, sends $returnObject to client $dataToSend = $this->getDataArrayWithErrors(); $jsonString = json_encode($dataToSend); die($jsonString); } } $GLOBALS['RETURN_PLUGIN'] = new serverReturnPluginObject(); ?>