php 通过include方式实现国际化多语言(i18n)
include实现国际化
将index.php进行翻译:
Index内容
1. Index
2. About us
我们可以将index.php设置为一个翻译模版,所有出现字符的地方,都定义为变量,如1,2部分设置为翻译的变量$menu_index, $menu_aboutus.
多种语言就有多种语言包,可以做成配置文件,比如en.inc.php cn.inc.php 等等
内容如下:
cn.inc.php
$menu_index='首页';
$menu_aboutus='关于我们';
en.inc.php
$menu_index='index';
$menu_about_us='about_us';
那么index.php根据参数的不同进行include不同的语言包,就翻译成相应的语言。
include方式 与 gettext() 比较
Gettext 优点:
Gettext()是实现i18n国际化,由于现在i18n越来越趋于国际化标准,得到广泛的支持,
缺点:
1.Php6版本之前还未完全的支持unicode,所以只支持常用的部分语言。
2.对已经存在的mo语言包文件进行了修改,得重启apache。
include方式 优点:
国际化实现简单,能支持所有语言。
缺点:
对要进行翻译的页面进行变量格式化,也就是做成一个翻译模版。比较繁杂。
php gettext方式实现UTF-8国际化多语言(i18n):
http://blog.csdn.net/wangking717/archive/2009/10/28/4739465.aspx
相关文档:
1、用PHP打印出前一天的时间格式是2006-5-10 22:21:21(2分)
2、echo(),print(),print_r()的区别(3分)
3、能够使HTML和PHP分离开使用的模板(1分)
4、使用哪些工具进行版本控制?(1分)
5、如何实现字符串翻转?(3分)
———————————& ......
可用于php的计数器和表单的提交,防止反复刷新。
复制代码
<?php
session_start();
$allow_sep = "30000";
if (isset($_SESSION["post_sep"]))
{
if (time() - $_SESSION["post_sep"] < $allow_sep)
{
exit("请不要反复刷新");
}
else
{
$_SESSION["post_sep"] = time();
}
}
e ......
1、mysql_connect()-建立数据库连接 {3RY4HVT?
格式: Fv n:V\eb
resource mysql_connect([string hostname [:port] [:/path/to/socket] [, string username] [, string password]]) _I;+p eq
例: 1(V>8}zn
$conn = @mysql_connect("localhost", "username", "password") or dir(" ......
openpne开源SNS
用PHP模拟126邮箱的登陆过程来收取邮件:http://www.cnblogs.com/amboyna/archive/2009/04/29/1446487.html
php调用其他系统的接口整理:http://blog.chinaunix.net/u2/84280/showart_2065156.html
问题:我是想写一个网上给手机发短信的功能 调用了一个第三方的飞信接口
飞信接口PHP版 (免费发短信) v1. ......
<?php
/*使用文本文件记录数据的简单实现*/
$counter=1;
if(file_exists("mycounter.txt")){
$fp=fopen("mycounter.txt","r");
$counter=fgets($fp,9);
$counter++;
fclose($fp);
}
$fp=fopen("mycounter.txt","w");
fputs($fp,$counter);
fclose($fp);
echo "<h1>您是第".$counter."次访问本页 ......