Class common_sms{protected static $ms _conf = Array (); Public Function __construct () {self:: $ms _conf = array (' url ' = = ' 1212 ', ' username ' = ' XXX ', ' password ' = ' OOO ', ' verycode ' = ' KKK '); } private static function curl_post ($method = ', $param = Array ()) {do {if (! $method | | empty ( $param) {$ret = array (' status ' = ' failed ', ' msg ' = > ' Invalid param ', ' results ' = ' Invalid parameters '); Break } $url = self:: $ms _conf[' url ']. Method= '. $method; } while (0); return $url; /** * Send verification code SMS * @param [type] $mobile phone number * @param array $param captcha:array (' Code ' = ' mi Nute ' + ') * @return Array Callback information */public static function Send ($mobile = ', $param = Array ()) { do{if (! $mobile) {$result = array (' status ' = ' failed ', ' results ' = ' = ') Missing [Mobile] parameter '); Break } if (!isset ($param [' Code ')]) {$result = array (' status ' = ' failed ', ' Results ' = ' and ' ERROR ' [code] parameter '); Break } $param _arr = Array (' mobile ' = $mobile, ' content ' = ' @1@={$param [ ' Code '} ', ' sendtime ' + ', ' msgtype ' = 2, ' tempid ' and ' J ' sm40485-0001 ', ' code ' = ' Utf-8 ',); $req _result = self::curl_post (' sendmsg ', $param _arr); if ($req _result[' status '] = = ' success ') {//$req _result = Trim ($req _result); $back _result = Explode (' # ', $req _result); if ($back _result[0] = = 0)//{ $result = Array (' status ' = ' success ', ' results ' = = Array (' send ' = ' = ' + ') ', ' Commit ' = $back _result[1])); }//else//{//$msg = Self::senderror ($back _res ULT); $result = Array (' status ' = ' failed ', ' results ' = = $msg); }//Return $req _result[' results '); } else {$result = array (' status ' = ' failed ', ' results ' = ' + ' $req _result[' msg ') ; Break }} while (0); return $result; }}
A PHP Error was encountered
Severity:notice
Message:Undefined index: url
filename:common/sms.php
Line number:32
No systematic reading of the book, Solving!!!
Reply content:
Class common_sms{protected static $ms _conf = Array (); Public Function __construct () {self:: $ms _conf = array (' url ' = = ' 1212 ', ' username ' = ' XXX ', ' password ' = ' OOO ', ' verycode ' = ' KKK '); } private static function curl_post ($method = ', $param = Array ()) {do {if (! $method | | empty ( $param) {$ret = array (' status ' = ' failed ', ' msg ' = > ' Invalid param ', ' results ' = ' Invalid parameters '); Break } $url = self:: $ms _conf[' url ']. Method= '. $method; } while (0); return $url; /** * Send verification code SMS * @param [type] $mobile phone number * @param array $param captcha:array (' Code ' = ' mi Nute ' + ') * @return Array Callback information */public static function Send ($mobile = ', $param = Array ()) { do{if (! $mobile) {$result = array (' status ' = ' failed ', ' results ' = ' = ') Missing [Mobile] parameter '); Break } if (!isset ($param [' Code ')]) {$result = array (' status ' = ' failed ', ' Results ' = ' and ' ERROR ' [code] parameter '); Break } $param _arr = Array (' mobile ' = $mobile, ' content ' = ' @1@={$param [ ' Code '} ', ' sendtime ' + ', ' msgtype ' = 2, ' tempid ' and ' J ' sm40485-0001 ', ' code ' = ' Utf-8 ',); $req _result = self::curl_post (' sendmsg ', $param _arr); if ($req _result[' status '] = = ' success ') {//$req _result = Trim ($req _result); $back _result = Explode (' # ', $req _result); if ($back _result[0] = = 0)//{ $result = Array (' status ' = ' success ', ' results ' = = Array (' send ' = ' = ' + ') ', ' Commit ' = $back _result[1])); }//else//{//$msg = Self::senderror ($back _res ULT); $result = Array (' status ' = ' failed ', ' results ' = = $msg); }//Return $req _result[' results '); } else {$result = array (' status ' = ' failed ', ' results ' = ' + ' $req _result[' msg ') ; Break }} while (0); return $result; }}
A PHP Error was encountered
Severity:notice
Message:Undefined index: url
filename:common/sms.php
Line number:32
No systematic reading of the book, Solving!!!
May I ask how you call that?
That static method of yours is private , how do you call this method?
When a static method is called, the constructor of the class is not automatically called.
So your $ms_conf is an empty array, so you should know the result?
执行结果:
tttarray(0) {}