我使用一个类来实现sms等,但由于我似乎无法从其他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');
}
}
根据我对你的问题的理解,你想在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