Quick Guide
This quick guide will show you how to use and create it to master and master the tutorial.
This quick guide will show you how to use and create it to master and master the tutorial.
Includes: Provides different ones for you to choose and use.
Run index.php to access the Homepage directory; for other pages, please refer to "Newpage".
Source: latest.zip -> /example/01-directory
Use the array() language structure to build an array and complete all operations through functions; compared to other versions, the portable version is completed by a file.
Source: latest.zip -> /example/02-portable
$global_lp_all = array('en-us', 'zh-cn', 'zh-tw', 'ja-jp', 'ko-kr', 'ru-ru');
$lpna = array (
'template' => array (
'en-us' => 'template',
'zh-cn' => '模板',
'zh-tw' => '模板',
'ja-jp' => '模板',
'ko-kr' => '模板',
'ru-ru' => '模板'),
'end' => array (
'en-us' => 'end',
'zh-cn' => 'end',
'zh-tw' => 'end',
'ja-jp' => 'end',
'ko-kr' => 'end',
'ru-ru' => 'end')
);
<?php echo $lpna['lang_page_title'][$lng]; ?>
Please pay attention to the writing of the array when using it, the array demo is only listed in part, please refer to the source code:latest.zip -> /example/02-portable/index.php
print_r($lpna);
In the process of using the portable version, such as pictures, ICOs, you need to convert to base64 encoding. Javascript, CSS and other resources are completed with embedded code. Shortening tools can be used.
Connects to SQL database through PDO, and supports MySQL and SQLite. And use the Array function to list all available data.
Source: latest.zip -> /example/03-database
Use template latest.zip -> /example/03-database/lp-config.sample.php File, change to new file name: lp-config.php
define('Database_Mode', '');
define('DB_HOST', 'localhost');
define('DB_NAME', 'lang-php');
define('DB_USER', 'username');
define('DB_PWD', 'password');
define('DB_PREFIX', 'lp_');
define('DB_CHARSET', 'utf8mb4');
include_once('lp-load.php');
$page_team = 'homepage';
$current_lng = $db->select(DB_PREFIX."translate", "section = '$page_team'");
$lpna = $db->arraymodify($current_lng, $lng);
See latest.zip -> /example/03-database/index.php File.
<?php echo $lpna['lang_use_title1']['lp_variable']; ?>
print_r($current_page);
print_r($lpna);
Use template latest.zip -> /example/03-database/templets.php File, the user can change it to the new file name (example: newpage.php).
Modify the current page name for indexing.
$page_team = 'newpage';
Supplement refers to the hidden usage and other functions in use.
What is Javascript (JS) to switch languages and hide parameters? The purpose is to remove the suffix.
Before using mode 1: https://fengyi.tel/php/?lang=zh-cn;
After using mode 2: https://fengyi.tel/php, the suffix is gone.
<html>
<headl>
<script src="../assets/js/lp.js"></script>
</headl>
<body>
<a href="?lang=en-us">Switch</a>
</body>
</html>
Source: latest.zip -> /example/*/../assets/js/lp.js
What is the jump to the specified domain name? Some examples are by reading and matching the files in the directory. If you want to jump to the specified domain name, please refer to the following code:
/* sample 1
header("Location: http://us.fengyi.tel/php");
/* sample 2
public $globalDomain = 'https://fengyi.tel/php/';
function loading($lang)
{
header("Location:" . $this->globalDomain . $lang);
}
/* sample 3
function loading($lang)
switch ($lang) {
case 'zh-cn': header("Location: https://cn.fengyi.tel/php"); break;
case 'zh-tw': header("Location: https://tw.fengyi.tel/php"); break;
case 'en-us': header("Location: https://us.fengyi.tel/php"); break;
case 'ru-ru': header("Location: https://ru.fengyi.tel/php"); break;
case 'ja-jp': header("Location: https://jp.fengyi.tel/php"); break;
case 'ko-kr': header("Location: https://kr.fengyi.tel/php"); break;
default: header("Location: https://global.fengyi.tel/php"); break;
}
}