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

getRandomString() public static method

获取随机字符
public static getRandomString ( $length = 10 )
    public static function getRandomString($length = 10)
    {
        $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
        return substr(str_shuffle(str_repeat($pool, ceil($length / strlen($pool)))), 0, $length);
    }

Usage Example

Ejemplo 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::getRandomString