/** * 设置$_POST请求资料 * @access public * @param string|array $spec * @param null|mixed $value * @param bool $filtration 是否过滤内容 默认为true * @return XF_Controller_Request_Http */ public function setPost($spec, $value = null, $filtration = true) { if (null === $value && is_array($spec)) { foreach ($spec as $key => $value) { $this->setPost($key, $value); } return $this; } $this->_post_params[(string) $spec] = XF_String::clearJs($value); $this->setParam((string) $spec, $value, $filtration); return $this; }
/** * 设置一个请求参数,如果设置的值为NULL,并且存在此参数key时,将删除该参数. * @access public * @param string $key * @param mixed $value * @param bool $filtration 是否过滤内容 默认为true * @return XF_Controller_Request_Abstract */ public function setParam($key, $value, $filtration = true) { if (null === $value && isset($this->_params[$key])) { unset($this->_params[$key]); } elseif (null !== $value) { if (strpos($key, '[]') !== false) { $key = str_replace('[]', '', $key); $this->_params[$key][] = $filtration ? XF_String::clearJs($value) : $value; } else { $this->_params[$key] = $filtration ? XF_String::clearJs($value) : $value; } } return $this; }