PHP - realize automatic switching of multiple languages
Dec 01, 2017 am 09:16 AMI believe that many students have browsed many websites with multi-language switching, and they feel that they are very good. Today, the editor has brought you an article about using PHP to perform automatic multi-language switching. introduce. I believe many students don’t know that PHP can also switch languages, so let us take a look at how PHP is implemented!
1. Add the following configuration in config.php of Home (the project name you chose)
1 2 3 4 5 6 7 8 9 10 |
|
2. Add a php file (tag.php) to the conf folder of Home and add the following code:
1 2 3 4 |
|
3. Copy the Extend/Behavior/CheckLangBehavior.class.php file to Home/lib/Behavior/ (only the full version of thinkphp package is available, if not, please create it yourself)
CheckLangBehavior.class.php code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
|
##4. In Home Create 3 language folders under the lang folder. They are zh-cn en-us zh-tw,
Create a common.php file in each of these three folders, as shown in the figure:
In common.php, write1 2 3 4 5 |
|
1 2 3 4 |
|
1 2 3 4 5 |
|
5. Create the view index.html# in the tpl/Index/ folder ##
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
Done!
If you want to switch the background language, in each sentence Add L before it, such as:
1 2 3 4 |
|
Related recommendations:
#php simple method to achieve multi-language switching, php language switching
phpHow to implement WeChat applet payment and refundphp Multi-language switchingThe above is the detailed content of PHP - realize automatic switching of multiple languages. For more information, please follow other related articles on the PHP Chinese website!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

How To Set Up Visual Studio Code (VS Code) for PHP Development
