php多语言简单实现办法

语言包:

if(isset($_GET['lang'])) {
$l = $_GET['lang'];
} else {
$l = getenv('HTTP_ACCEPT_LANGUAGE');
$l = strtolower(substr($l,0,2));
}
$l = ($l == 'zh' || $l == 'en') ? $l : 'cn';

$lang = array();
$lang['en'][0] = 'php simple implementation of multi-language approach abc';
$lang['zh'][0] = 'php多語言簡單實現辦法';
$lang['cn'][0] = 'php多语言简单实现办法';

模板:

echo $lang[$l][0];

请求:
http://localhost/?lang=cn

转载请注明出处:https://www.onexin.net/php-simple-implementation-of-multi-language-approach/

随机文章:

1、DX无后缀名图片下载,后缀名指(.jpg/.gif)
https://www.onexin.net/dx-extension-picture-download-extension-means-jpg-gif/

2、超赞,WP3.2中新增了一套HTML5的主题模板
https://www.onexin.net/fabulous-wp3-2-in-a-new-theme-template-html5/

3、Extreme Picture Finder 3.4
https://www.onexin.net/extreme-picture-finder-34/

4、Wordpress自定义时间和日期
https://www.onexin.net/wordpress-custom-time-and-date/

5、主域名和二级域名设置不同DNS服务器解决方法
https://www.onexin.net/the-main-domain-and-two-domain-solution-to-set-up-the-ns-records-ns-server-name/

Leave a Reply