/** *获取put,post,get,delete等数据的处理,并在此处做验证 **/ public function __get($name) { $method = strtolower($_SERVER['REQUEST_METHOD']); $name = strtolower($name); switch ($name) { case 'put': if ($method == 'put') { $content = file_get_contents('php://input'); $input = json_decode($content, true); } case 'post': if (!isset($input) && $method == 'post') { $content = file_get_contents('php://input'); $input = json_decode($content, true); } case 'get': if (!isset($input) && $method == 'get') { $input = $this->_get(); } case 'delete': if (!isset($input) && $method == 'delete') { $input = $this->_get(); } if ($method == $name) { return $input; } else { $this->api_error($name); } break; case 'request_method': return $method; break; default: return parent::get($name); break; } }