php做项目进行中英文的切换,如何快速实现

WBOY
Release: 2016-06-23 13:42:55
Original
1817 people have browsed it

这个是我在做项目的时候总结的方法,当然如果你们有更好的方法也可以和我分享一下

一般我会建议建2个文件,一个中文的一个英文的

在视图页面:

<div class="top">      <div class="contenters">        <a href="<?php echo APP::URL($page,array('language'=>'cn')); ?>">中文</a>        <a href="<?php echo APP::URL($page,array('language'=>'en')); ?>">English</a>      </div></div>
Copy after login

在控制器页面:

$page = 'newexhibitors';if(isset($_GET['language'])){   if($_GET['language']=='cn'){       $_SESSION['lan'] = 'cn';       $title = '测试';       require APP::TPL('newexhibitors');   }else if($_GET['language']=='en'){       $_SESSION['lan'] = 'en';       $title = 'Test';       require APP::TPL('en_newexhibitors');   }}else{    if($_SESSION['lan']){       if($_SESSION['lan']=='cn'){            $title = '测试';            require APP::TPL('newexhibitors');       }else{            $title = 'Test';            require APP::TPL('en_newexhibitors');       }    }else{       $_SESSION['lan']='cn';       $title = '测试';       require APP::TPL('newexhibitors');    }}
Copy after login

这个代码实现的效果,点击“中/英”文切换时,自动在当前页面进行切换

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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!