preg_match("/[\]/",'',$body);
我使用 preg_match 但我在这里有这个错误
编译失败:在偏移量 3 处缺少字符类的终止 ]
这里有什么问题我找不到
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Full Name: ".clean_string($_POST['full_name'])."\n";
$email_message .= "Email: ".clean_string($_POST['email'])."\n";
$email_message .= "Telephone number: ".clean_string($_POST['telephone'])."\n";
$email_message .= "Message: ".clean_string($_POST['comments'])."\n";
$mail = new PHPMailer();
$body = $email_message;
$body = str_replace('\\', '', $body);
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "hanem@gmail.com"; // GMAIL username
$mail->Password = "hinadk"; // GMAIL password
$mail->SetFrom('from-email@domain.com', 'First Last');
$mail->Subject = "Imperia";
$mail->AltBody = "To view the message, please use an HTML compatidble email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$address = "hanem@gmail.com";
$mail->AddAddress($address, "To Name");
if(!$mail->Send()) {
echo "<font color='red'> Message error </font>". $mail->ErrorInfo;
} else {
echo "<font color='red'> Message sent </font>";
}
有 eregi_replace("[]",'',$body);
但我有另一个错误,因此我将其更改为 preg_match