PHP中实现汉字转区位码应用源码实例解析

yipeiwu_com5年前PHP代码库
复制代码 代码如下:

<?php
global $PHP_SELF;
//echo $PHP_SELF;
$t1=$_POST['textfield1'];
$t2=$_POST['textfield2'];
$t3=$_POST['textfield3'];
$t4=$_POST['textfield4'];
// 汉字--区位码
if($t1!=""){
$t2= sprintf("%02d%02d",ord($t1[0])-160,ord($t1[1])-160);
//echo $t2;
}
// 区位码--汉字
if($t3!=""){
$t4 = chr(substr($t3,0,2)+160).chr(substr($t3,2,2)+160);
//echo $t4;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
.STYLE1 {font-size: 18px}
-->
</style>
</head>
<body>
<table width="528" height="146" border="1"
align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="524" height="50"><div align="center"
class="STYLE1">汉字区位码查询系统</div></td>
</tr>
<tr>
<td><form id="form1" name="form1" method="post" action=
"<?=$PHP_SELF ?>">
<label>输入汉字
<input name="textfield1" type="text" value="<?=$t1?>" />
</label>
<label>
<input type="submit" name="Submit" value=" 转 换 " />
</label>
<label>
<input name="textfield2" type="text" value="<?=$t2?>" />
</label>
</form>
<br />
<form id="form2" name="form2" method="post" action="<?=$PHP_SELF ?>">
<label>输入区位码
<input name="textfield3" type="text" value="<?=$t3?>" />
</label>
<input type="submit" name="Submit2" value=" 转 换 " />
<input name="textfield4" type="text" value="<?=$t4?>" />
</form>
</td>
</tr>
</table>
</body>
</html>

相关文章

PHP 类型转换函数intval

PHP代码 $id = intval($_GET['id']); intval (PHP 4, PHP 5) intval — Get the integer value of a va...

php使用function_exists判断函数可用的方法

本文实例讲述了php使用function_exists判断函数可用的方法。分享给大家供大家参考。具体如下: 本文所述的函数用来建立一张 gif 格式图形,参数 im 为使用 imagec...

apache和php之间协同工作的配置经验分享

php在当今一个不陌生的网络技术名词,想到网站或者web可能大多数开发者都会想到php,一个既免费又开源,既容易又实用等一些好处才拥有了世界上很多IT技术人员的青睐,我是一名JAVA开发...

微信公众平台开发教程①获取用户Openid及个人信息图文详解

微信公众平台开发教程①获取用户Openid及个人信息图文详解

本文实例讲述了微信公众平台开发获取用户Openid及个人信息。分享给大家供大家参考,具体如下: 前言: 初次尝试微信公众号的开发,对于学习方法的探索都是来源于网上的博客、问答,对于参差...

PHP在获取指定目录下的目录,在获取的目录下面再创建文件,多平台

复制代码 代码如下: //取得指定文件夹的目录名称 function get_dir_name($dir_path,$file) { $dirpath = $dir_path; $dir...