初始化代码
This commit is contained in:
56
application/api/wxapi/wxmsg/Base.php
Normal file
56
application/api/wxapi/wxmsg/Base.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user