57 lines
1.0 KiB
PHP
57 lines
1.0 KiB
PHP
<?php
|
|
namespace app\api\wxapi\wxmsg;
|
|
|
|
class Base
|
|
{
|
|
protected $OtherData=[];
|
|
|
|
public static function className()
|
|
{
|
|
return get_called_class();
|
|
}
|
|
|
|
public function __construct()
|
|
{
|
|
$this->init();
|
|
}
|
|
|
|
public function init()
|
|
{
|
|
}
|
|
|
|
public function __get($name){
|
|
$getter='get'.$name;
|
|
if(method_exists($this, $getter)){
|
|
return $this->$getter();
|
|
}else if(isset($this->OtherData[$name])){
|
|
return $this->OtherData[$name];
|
|
}
|
|
return '';
|
|
}
|
|
|
|
public function __set($name, $value){
|
|
$setter='set'.$name;
|
|
if(method_exists($this, $setter)){
|
|
$this->$setter($value);
|
|
}else{
|
|
$this->OtherData[$name]=$value;
|
|
}
|
|
}
|
|
|
|
protected function nonceStr($len)
|
|
{
|
|
$chars='ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
|
|
$arr=[];
|
|
for($i=0;$i<strlen($chars);$i++){
|
|
$arr[]=$chars{$i};
|
|
}
|
|
shuffle($arr);
|
|
$arr=array_chunk($arr,$len);
|
|
$arr=array_shift($arr);
|
|
$arr=strtoupper(implode("",$arr));
|
|
return $arr;
|
|
}
|
|
|
|
|
|
}
|