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

随机文章:

1、网络图形效果探索(五)
https://www.onexin.net/%e7%bd%91%e7%bb%9c%e5%9b%be%e5%bd%a2%e6%95%88%e6%9e%9c%e6%8e%a2%e7%b4%a2%ef%bc%88%e4%ba%94%ef%bc%89/

2、用户体验:JS实现仿新浪信息提示效果
https://www.onexin.net/the-user-experience-js-to-achieve-the-effect-of-imitation-sina-information-tips/

3、javascript单引号和双引号的区别以及使用方法
https://www.onexin.net/javascript-single-and-double-quotes-and-use-the-difference-between/

4、CSS样式编写的规范和常见问题
https://www.onexin.net/css-styles-to-prepare-specifications-and-frequently-asked-questions/

5、自主创业 网上开店是不错的选择
https://www.onexin.net/%e8%87%aa%e4%b8%bb%e5%88%9b%e4%b8%9a-%e7%bd%91%e4%b8%8a%e5%bc%80%e5%ba%97%e6%98%af%e4%b8%8d%e9%94%99%e7%9a%84%e9%80%89%e6%8b%a9/

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

Leave a Reply

Your email address will not be published. Required fields are marked *