- Constants can be defined with define(), for example: define("_MI_MOD_TITLE","title:");
- Constants usually start with "_" and use "uppercase English" for identification.
- PHP constants need to be inserted into the string. You cannot put the constants directly into the string (otherwise the program will not be able to figure out whether it is a string or a constant). The method is as follows:
- Original string→$aa="<div>title</div>";
- Set constant →$aa="<div>". _MI_MOD_TITLE. "</div>";
File name | use | Constant start | Use range |
---|---|---|---|
modinfo.php | Set language | _MI | Xoops_version.php and admin/menu.php only |
admin.php | Background language | _MA or _AM | All files except menu.php under admin |
main.php | Front desk language | _MD | All files in the front desk (except xoops_version.php) |
blocks.php | Block language | _MB | All files under blocks |
-
You can use sprintf() to combine constants and variables. The name of a constant can use "%s" to represent a variable. There can be multiple "%s" in a constant, which corresponds to the variable by position, for example:
define("_MD_MOD_INFO","本模組由 %s 於 %s 做最後更新"); $info=sprintf(_MD_MOD_INFO , $name , $update);
<{$smarty.const._語系常數}>
- The language in language/tchinese_utf8/global.php of XOOPS can be directly applied to each module.
- For the language of TadTools module tadtools/language/tchinese_utf8/main.php, only import tad_function.php, which can also be directly applied.