解析错误:语法错误,意外的T

我收到此错误:解析错误:语法错误,第8行/Applications/XAMPP/xamppfiles/htdocs/core/functions/users.php中的意外T_STRING

即时得到错误的那段代码是:

function recover($mode, $email) {
    $mode   = sanitize($mode);
    $email  = sanitize($email);

    $user_data = user_data(user_id_from_email($email), 'first_name', 'username');

    if ($mode == 'username') {
        email($email, 'Your username', 'Hello " . $user_data['first_name'] . ", nn Your username is: " . $user_data['username'] . " ');
    } elseif ($mode == 'password') {
        $generated_password = substr(md5(rand(999, 999999)), 0, 8);
        die($generated_password);
    }

}

我怎样才能解决这个问题? 提前致谢


您的语法对于以下行不正确:

email($email, 'Your username', 'Hello " . $user_data['first_name'] . ", nn Your username is: " . $user_data['username'] . " ');

您可以将其替换为:

email($email, 'Your username', "Hello " . $user_data['first_name'] . ", nn Your username is: " . $user_data['username'] . " ");

但更简洁的方法是将变量嵌入到字符串中:

email($email, 'Your username', "Hello {$user_data['first_name']}, nn Your username is: {$user_data['username']} ");
链接地址: http://www.djcxy.com/p/69483.html

上一篇: Parse error: syntax error, unexpected T

下一篇: Warning: Unexpected character in input: '\' (ASCII=92) state=0