Thenbsp\Wechat\Bridge\Util::getClientIp PHP Method

getClientIp() public static method

获取客户端 IP
public static getClientIp ( )
    public static function getClientIp()
    {
        $headers = function_exists('apache_request_headers') ? apache_request_headers() : $_SERVER;
        return isset($headers['REMOTE_ADDR']) ? $headers['REMOTE_ADDR'] : '0.0.0.0';
    }

Usage Example

Exemplo n.º 1
0
 /**
  * 合并和校验参数
  */
 public function resolveOptions()
 {
     $defaults = array('nonce_str' => Util::getRandomString(), 'client_ip' => Util::getClientIp());
     $resolver = new OptionsResolver();
     $resolver->setDefined($this->required)->setRequired($this->required)->setDefaults($defaults);
     return $resolver->resolve($this->toArray());
 }
All Usage Examples Of Thenbsp\Wechat\Bridge\Util::getClientIp