2017-10-05 50 views
0

我有我的網站上實施的聯繫表格。最近我決定製作頁面多語言。一切正常,但我不知道如何在發送電子郵件後彈出的聯繫表單消息中實現它。還有例如它是如何原來寫:多語言PHP聯繫表格,可以嗎?

if(empty($_POST["userName"])) { 
     $output = json_encode(array('type'=>'error', 'text' => '<i class="icon ion-close-round"></i> We are sorry but Your name is too short.')); 
     die($output); 
    } 

,我想改變文本「很抱歉,你的名字是太短了。」與之呼應我的語言PHP文件,這裏的例子:

echo htmlspecialchars($lang['warning']); 

在lang.php文件有:

$lang["warning"] = "We are sorry but Your name is too short."; 

是它在某種程度上可能嗎?感謝您的任何意見:)

回答

1

簡單的串聯字符串應該工作:

if(empty($_POST["userName"])) { 
    $output = json_encode(array('type'=>'error', 'text' => '<i class="icon ion-close-round"></i> ' . htmlspecialchars($lang['warning']))); 
    die($output); 
} 
+0

工作就像魅力,非常感謝你:) –