【发布时间】:2014-09-27 23:51:59
【问题描述】:
我正在使用 twilio 发送短信。如果我直接插入我的号码8881231234,它将起作用。下面的代码有效:
$client = new Services_Twilio($sid, $token);
$message = $client->account->messages->sendMessage(
'9991231234', // From a valid Twilio number
'8881231234', // Text this number
"Hello monkey!" //insert message here
);
print $message->sid;
但是当我通过从数据库中添加记录来替换它时,它将不起作用。如下所示,它不起作用:
echo $row2["handset"]; // I can see my number
$client = new Services_Twilio($sid, $token);
$message = $client->account->messages->sendMessage(
'9991231234', // From a valid Twilio number
'$row2["handset"]', // Text this number
"Hello monkey!"
);
print $message->sid;
我回显$row2["handset"],我的号码8881231234 显示正确。这也不起作用:
$handset = '8881231234';
$client = new Services_Twilio($sid, $token);
$message = $client->account->messages->sendMessage(
'9991231234', // From a valid Twilio number
'$handset', // Text this number
"Hello monkey!" // insert message here
);
print $message->sid;
这是为什么呢?请帮帮我。
【问题讨论】:
-
PHP 101:
'$row2["handset"]'不是一个数字......注意$row2["handset"]周围的那些引号('),使它成为一个文字字符串......同样引用'$handset'
标签: php mysql arrays string twilio