Home > php教程 > php手册 > 多语言切换按钮的实现

多语言切换按钮的实现

WBOY
Release: 2016-06-07 11:43:52
Original
1790 people have browsed it

多语言网站,肯定会有一个切换语言的按钮,之前懒一直用?l=en_us 和 ?l=zh-cn来实现,但是发现对搜索引擎不好,而且切换语言会形成一长串尾巴,后来发了小小时间改用一个自定函数来实现

langurl
模板文件中
header.html如下写:<ul> <br>             <li> <br>             <li><a>中文</a></li> <br>             <li><a>English</a></li> <br>         </ul>下面代码加到common/common.phpfunction langurl($lng)<br> {<br>     if (strpos(__SELF__,'?')===false)<br>     {<br>         echo __SELF__.'?l='.$lng;<br>     }else{<br>         echo substr(__SELF__,0,strpos(__SELF__,'?')).'?l='.$lng;<br>     }<br> }效果看:http://tou.mobi/v/56416d03c40efe46

AD:真正免费,域名+虚机+企业邮箱=0元

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template