endchar() static public method

获取字符串最后一位
static public endchar ( $string ) : mixed
$string
return mixed
Example #1
0
 function get($params = null, $cache_id = '')
 {
     $url = $this->config['url'];
     if ($params) {
         if (Tool::endchar($url) == '&') {
             $url .= http_build_query($params);
         } else {
             $url .= '?' . http_build_query($params);
         }
     }
     if (!empty($this->config['cache'])) {
         if (empty($cache_id)) {
             $cache_id = md5($url);
         }
         $cache_key = self::CACHE_KEY_PREFIX . $cache_id;
         $result = \Swoole::$php->cache->get($cache_key);
         if ($result) {
             return $result;
         }
     }
     $result = $this->_curl->get($url);
     if ($result and $this->_curl->info['http_code'] == 200) {
         if (!empty($this->config['json'])) {
             $result = json_decode($result, true);
         } elseif (!empty($this->config['serialize'])) {
             $result = unserialize($result);
         }
         if (!empty($this->config['cache'])) {
             \Swoole::$php->cache->set($cache_key, $result, $this->config['lifetime']);
         }
     }
     $this->info = $this->_curl->info;
     return $result;
 }