如何合并这个PHP脚本,使一个错误消息


How to merge this PHP script to make one error message?

我试图合并多个字符串,虽然它似乎只是抛出一个错误。

// Regex Tests
$error_message = "";
// Expressions
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+'.[A-Za-z]{2,4}$/';
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($email_exp, $email_from)) {
    $error_message + 'The Email Address you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp, $first_name)) {
    $error_message + 'The First Name you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp, $last_name)) {
    $error_message + 'The Last Name you entered does not appear to be valid.<br />';
}
if(!empty($error_message)) {
    formError($error_message);
}

之后:

if(strlen($comments) < 2) {
    $error_message .= 'The Comments you entered do not appear to be valid.<br />';
 }

把这个:

require_once('php/recaptchalib.php');
$privatekey = "enter private key";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
    $error_message .= 'The reCAPTCHA wasn't entered correctly. Go back and try it again.<br />';
}