public function detectLanguage() { $input = Input::getInstance('SERVER'); //strstr()需要PHP5.3.0以上版本支持第三个参数,如果找不到,返回false $language = strstr($input->get('LANG', ''), '.', true); if (empty($language)) { $accept = $input->get('HTTP_ACCEPT_LANGUAGE', ''); preg_match_all('/([a-z]{2}\\-?[A-Z]{0,2})/', $accept, $matches); foreach ($matches[0] as $language) { $language = str_replace('-', '_', $language); if (file_exists($this->locale_dir . '/' . $language)) { break; } } } return $language; }
public static function getClientIP() { return Input::getClientIP(); }