2016-03-07 105 views
-1

你好,我是用手机短信发送者在PHP中,我得到这个错误注意:使用未定义的常量方法 - 假设

Notice: Use of undefined constant method - assumed

这是我的代码

<?php 
//////// 
/* Sender SMS */ 
//////// 

    $request =""; //initialise the request variable 
    $param[method]= "sendMessage"; 
    $param[send_to] = "91".$_SESSION['yourContact']; 
    $param[msg] = "vamsi biyah hello the sms is working ahhahahahah :D :D " . $_SESSION['tour_id'] . ""; 
    $param[userid] = $sms_userid; 
    $param[password] = $sms_pass; 
    $param[v] = "1.1"; 
    $param[msg_type] = "TEXT"; //Can be "FLASH”/"UNICODE_TEXT"/”BINARY” 
    $param[auth_scheme] = "PLAIN"; 
    //Have to URL encode the values 
    foreach($param as $key=>$val) { 
     $request.= $key."=".urlencode($val); 
    //we have to urlencode the values 
     $request.= "&"; 
    //append the ampersand (&) sign after each parameter/value pair 
    } 
    $request = substr($request, 0, strlen($request)-1); 
    //remove final (&) sign from the request 
    $url = "http://enterprise.smsgupshup.com/GatewayAPI/rest?".$request; 
    $ch = curl_init($url); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
    $curl_scraped_page = curl_exec($ch); 
    curl_close($ch); 
    //echo $curl_scraped_page; 

?> 

,这就是错误我得到:

Notice: Use of undefined constant method - assumed 'method' 
Notice: Use of undefined constant send_to - assumed 'send_to' 
Notice: Use of undefined constant msg - assumed 'msg' 
Notice: Use of undefined constant userid - assumed 'userid' 
Notice: Use of undefined constant password - assumed 'password' 
Notice: Use of undefined constant v - assumed 'v' 
Notice: Use of undefined constant msg_type - assumed 'msg_type' 
Notice: Use of undefined constant auth_scheme - assumed 'auth_scheme' 

任何人都可以请帮助我了解什么是这个错误,我该如何解决它?

+0

在数组键中使用单引号:'$ param ['method']'et c ...查看[这个答案](http://stackoverflow.com/a/2941174/3294262)了解更多信息 – fusion3k

回答

1

您需要使用引号索引,否则将被它视为常数变量:

例子:

$param['method']= "sendMessage"; 
$param['send_to'] = "91".$_SESSION['yourContact']; 
$param['msg'] = "vamsi biyah hello the sms is working ahhahahahah :D :D " . $_SESSION['tour_id'] . ""; 
$param['userid'] = $sms_userid; 
$param['password'] = $sms_pass; 
$param['v'] = "1.1"; 
$param['msg_type'] = "TEXT"; //Can be "FLASH”/"UNICODE_TEXT"/”BINARY” 
$param['auth_scheme'] = "PLAIN"; 
0

尝试使用'您的阵列产品,比如说

$param['method']它解决您的问题