PHP

MULTI-LANGUAGE WEBSITES WITH PHP

<header><?=$_TXT[0]?></header>   <main><?=$_TXT[1]?></main>   <footer><?=$_TXT[2]?></footer>

VARIABLE TEXT PLACEHOLDERS

01

PHP MANAGE LANGUAGE session_start(); if (!isset($_SESSION["lang"])) {    $_SESSION["lang"] = "en"; } if (isset($_POST["lang"])) {   $_SESSION["lang"] = $_POST["lang"]; } require "lang-" . $_SESSION["lang"] . ".php";

LANGUAGE SWITCHER

02

HTML LANGUAGE FORM <form method="post">   <input type="submit" name="lang"                value="en"/>   <input type="submit" name="lang"                value="zh"/>  </form>

ENGLISH (LANG-EN.PHP) $_TXT = [ "My Website", "Welcome To My Site", "Copyright My Site" ];

LANGUAGE PACKS

03

CHINESE (LANG-ZH.PHP) $_TXT = [ "我的网站", "欢迎来到我的网站", "版权所有: 我的网站" ];