我正在 PHP 中创建一个 API,但它不能组合两个变量

I'm making an API in PHP, but it cannot combine two variables

我正在尝试为 PHP 中的 SMS 消息程序制作 API。除一件事外,一切正常并检查。它得到 &carrier&number 但 PHP 似乎无法将它们组合起来。有什么建议么?我试过调试它。

URL是:https://www.swiftresolver.com/sms/api.php?number=number@txt.att.net&from=faded&message=hi&subject=hi&amount=3&carrier=ATT

我的全部代码:

<br>
<br>
<b>Debugging info:</b>
<br>
<?php
$number = trim(strtolower($_GET['number']));
$from = trim(strtolower($_GET['from']));
$message = trim(strtolower($_GET['message']));
$subject = trim(strtolower($_GET['subject']));
$amount = trim(strtolower($_GET['amount']));
$number2 = $number. "@" .$carrier;
print_r($_GET);
require 'PHPMailerAutoload.php';
switch($_GET['carrier']){
    case 'AT&T':
  $carrier = "txt.att.net";
    break;
    case 'Sprint':
  $carrier = "messaging.sprintpcs.com";
    break;
    case 'Verizon':
  $carrier = "vtext.com";
    break;
    case 'T-Mobile':
  $carrier = "tmomail.net";
    break;
    case 'Soufian':
  $carrier = "gin.nl";
    break;
}
$mail = new PHPMailer;
$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'swiftserver.ddns.net';                       // Specify main and backup server
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'server@swiftserver.ddns.net';                   // SMTP username
$mail->Password = 'xxxxxxx';               // SMTP password
$mail->Port = 25591;                                    //Set the SMTP port number - 587 for authenticated TLS
$mail->setFrom('fbi@fbi.gov',$from);     //Set who the message is to be sent fr
$mail->AddAddress($number2);               // Name is optional
$mail->WordWrap = 50;                                 // Set word wrap to 50 characters
$mail->isHTML(true);                                  // Set email format to HTML
$mail->Subject = ''.$subject;
$mail->Body    = ''.$message;
if ($amount > 50){
print("You can only send 50 messages at a time. Change the message number to 50 and refresh the page.");
}
else if($amount < 50){
for($i=0; $i < $amount; $i++)
{
if(!$mail->send()) {
   echo 'Message could not be sent: ';
   echo '' . $mail->ErrorInfo;
   exit;
}
}
echo 'Your message has been sent ' .$amount;
echo ' time(s).';
}
?>
<html>
<br>
<br>
<br>
<br>

我遇到了问题

$number2 = $number. "@" .$carrier;

我可能错了,但请尝试将此行 $number2 = $number. "@" .$carrier; 放在 switch 语句之后,因为看起来您只在 switch 中声明了 $carrier。希望这有效。

OP代表回答:

在switch函数中,我只是把AT&T改成了ATT