2017-10-05 80 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

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