我使用一个类来实现短信等,但由于我似乎无法从其他php页面获得的变量,它不会在100%触发。 我需要在if语句中添加更多变量,以便sms消息对于用户输入的状态和类型等是唯一的, 所以基本代码如下,我将不胜感激。
$acc_id = $upd->getField('account_id');
$status = $upd->getField('status');
$meetingtype = $upd->getField('');
error_log($status);
//show me how to add account name? accounts.name
$acc_id = $upd->getField('account_id');
$acc = new Account();
$acc->retrieve($acc_id);
$acc->primary_phone;
error_log($acc->name);
$sms = new DawproSms();
$sms->number = $acc->primary_phone;
$themeetingtype = $upd->getField('');
$theStatus = $upd->getField('status');
if ($theStatus == 'Held')
{
$sms->message = "Your Moovah removal is confirmed for <date><time>@ <location>. Should you have any questions, kindly contact SA Taxi on 0861 88 99 88.";
$sms->number = '0123456789';
$return = $sms->send();
if ($return){
error_log('SMS Sent!');
} else {
error_log('There was a problem sending the SMS');
}
}
else if ($theStatus == 'Held')
{
$sms->message = "Your SA Taxi Media removal is confirmed for <date><time>@ <location>. Should you have any questions, kindly contact SA Taxi on 0861 88 99 88.";
$sms->number = '0123456789';
$return = $sms->send();
if ($return){
error_log('SMS Sent!');
} else {
error_log('There was a problem sending the SMS');
}
}
else if ($theStatus == 'Held')
{
$sms->message = "Your SA Taxi Media and Moovah removal is confirmed for <date><time>@ <location>. Should you have any questions, kindly contact SA Taxi on 0861 88 99 88.";
$sms->number = '0123456789';
$return = $sms->send();
if ($return){
error_log('SMS Sent!');
} else {
error_log('There was a problem sending the SMS');
}
}
else if ($theStatus == 'Accepted')
{
$sms->message = "Your Moovah branding replacement is confirmed for <date><time>@ <location>. Questions? Contact SA Taxi on 0861 88 99 88.";
$sms->number = '0123456789';
$return = $sms->send();
if ($return){
error_log('SMS Sent!');
} else {
error_log('There was a problem sending the SMS');
}
}
答案 0 :(得分:0)
根据我的理解,您的IF句中需要多个条件?如果是这种情况,你可以这样做:
if($theStatus == 'Held' && $status== 'Mover'){
//code
}
但是,如果你只想在一个字段/变量上验证,你也可以这样做:
switch($theStatus){
case "Held":
//sms code thing
break;
case "Accepted":
//Sms code thing
break
}
您可以在此处查看有关切换的更详细说明:http://php.net/manual/en/control-structures.switch.php