Static variables/methods

Source: Internet
Author: User
{Code...} APHPErrorwasencounteredSeverity: NoticeMessage: Undefinedindex: urlFilename: commonsms. phpLineNumber !!!
Class Common_Sms {protected static $ ms_conf = array (); public function _ construct () {self: $ ms_conf = array ('url' => '2016 ', 'username' => 'xxx', 'Password' => 'ooo', 'verycode' => 'kkk ');} private static function curl_post ($ method = '', $ param = array () {do {if (! $ Method | empty ($ param) {$ ret = array ('status' => 'failed', 'msg '=> 'invalidparam ', 'results' => 'invalid parameter'); 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' =>, 'minute '=>) * @ return array return information */public static function send ($ mobile = '', $ param = array ()) {do {if (! $ Mobile) {$ result = array ('status' => 'failed', 'results' => 'parameter [mobile] missing'); break;} if (! Isset ($ param ['code']) {$ result = array ('status' => 'failed ', 'results' => 'incorrect [code] parameter'); break;} $ param_arr = array ('mobile' => $ mobile, 'content' => "@ 1 ={$ param ['code']}", 'sendtime' => '', 'msgtype' => 2, 'tempid' => 'jsm401_100', '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' => $ back_result [2], 'commit '=> $ back_result [1]); ///} // else // {// $ msg = self: sendError ($ back_result); // $ result = array ('status' => 'failed ', 'result' => $ msg); // return $ req_result ['result'];} 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

I have read books without a system !!!

Reply content:
Class Common_Sms {protected static $ ms_conf = array (); public function _ construct () {self: $ ms_conf = array ('url' => '2016 ', 'username' => 'xxx', 'Password' => 'ooo', 'verycode' => 'kkk ');} private static function curl_post ($ method = '', $ param = array () {do {if (! $ Method | empty ($ param) {$ ret = array ('status' => 'failed', 'msg '=> 'invalidparam ', 'results' => 'invalid parameter'); 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' =>, 'minute '=>) * @ return array return information */public static function send ($ mobile = '', $ param = array ()) {do {if (! $ Mobile) {$ result = array ('status' => 'failed', 'results' => 'parameter [mobile] missing'); break;} if (! Isset ($ param ['code']) {$ result = array ('status' => 'failed ', 'results' => 'incorrect [code] parameter'); break;} $ param_arr = array ('mobile' => $ mobile, 'content' => "@ 1 ={$ param ['code']}", 'sendtime' => '', 'msgtype' => 2, 'tempid' => 'jsm401_100', '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' => $ back_result [2], 'commit '=> $ back_result [1]); ///} // else // {// $ msg = self: sendError ($ back_result); // $ result = array ('status' => 'failed ', 'result' => $ msg); // return $ req_result ['result'];} 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

I have read books without a system !!!

How did you call it?
Your static method isprivateHow do you call this method?

When a static method is called, the class constructor is not automatically called.
So your$ms_confIt is an empty array, so you should understand the result?


  

Execution result:

tttarray(0) {}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.