如何通过tips-1048079-01.php实现高效代码优化?
- 内容介绍
- 文章标签
- 相关推荐
本文共计112个文字,预计阅读时间需要1分钟。
phpclass WeChat{ private $appid; private $appsecret; private $token;
public function __construct($appid, $appsecret, $token) { $this->appid=$appid; $this->appsecret=$appsecret; $this->token=$token; }}
class WeChat { private $_appid; private $_appsecret; private $_token; public function __construct($appid, $appsecret, $token) { $this->_appid = $appid; $this->_appsecret = $appsecret; $this->_token = $token; } public function valid() { $echoStr = $_GET["echostr"]; //valid signature , option if($this->checkSignature()) { echo $echoStr; exit; } } private function checkSignature() { $signature = $_GET["signature"]; $timestamp = $_GET["timestamp"]; $nonce = $_GET["nonce"]; $token = $this->_token; $tmpArr = array($token, $timestamp, $nonce); sort($tmpArr); $tmpStr = implode( $tmpArr ); $tmpStr = sha1( $tmpStr ); if( $tmpStr == $signature ) { return true; } else { return false; } } }
本文共计112个文字,预计阅读时间需要1分钟。
phpclass WeChat{ private $appid; private $appsecret; private $token;
public function __construct($appid, $appsecret, $token) { $this->appid=$appid; $this->appsecret=$appsecret; $this->token=$token; }}
class WeChat { private $_appid; private $_appsecret; private $_token; public function __construct($appid, $appsecret, $token) { $this->_appid = $appid; $this->_appsecret = $appsecret; $this->_token = $token; } public function valid() { $echoStr = $_GET["echostr"]; //valid signature , option if($this->checkSignature()) { echo $echoStr; exit; } } private function checkSignature() { $signature = $_GET["signature"]; $timestamp = $_GET["timestamp"]; $nonce = $_GET["nonce"]; $token = $this->_token; $tmpArr = array($token, $timestamp, $nonce); sort($tmpArr); $tmpStr = implode( $tmpArr ); $tmpStr = sha1( $tmpStr ); if( $tmpStr == $signature ) { return true; } else { return false; } } }

