借了本关于wml和xml的书。打算自己弄个wap 竹叶。先在网上看一下有关的教程,发现蓝色理想论坛里的wap区很多有用的资料哦!
【WAP中文字符传递 PHP解决方案】
现在给出PHP中的完美解决方案,无论是采用普通ASCII码,还是UTF-8格式存储,提交的中文字符奇偶,都没有问题。采用普通文件格式ASCII码存储,保存为testgb.php
<?php header("Content-Type: text/vnd.wap.wml;charset=GB2312"); echo '<?xml version="1.0" encoding="GB2312"?>'; echo '<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">'; ?> <wml> <card id="main" title="PHP Web"> <p> GET提交,结果: <?php echo iconv("utf-8", "gb2312",$_GET["name"]);?><br/> POST提交,结果: <?php echo iconv("utf-8", "gb2312",urldecode($_POST["name"])); ?><br/> <input name="name" emptyok="false" tabindex="2" format="*m"/> <a href="testgb.php?name=$(name:e)">提交aaa</a><br/> <anchor>提交anchor <go href="testgb.php" method="post"> <postfield name="name" value="$(name:e)" /> </go> </anchor><br/> </p> </card> </wml>采用UTF-8格式存储,保存为test_utf.php
<?php header("Content-Type: text/vnd.wap.wml;charset=UTF-8"); echo '<?xml version="1.0" encoding="UTF-8"?>'; echo '<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">'; ?> <wml> <card id="main" title="PHP Web"> <p> GET提交,结果: <?php echo $_GET["name"]; ?><br/> POST提交,结果: <?php echo urldecode($_POST["name"]); ?><br/> <input name="name" emptyok="false" tabindex="2" format="*m"/> <a href="test_utf.php?name=$(name:e)">提交aaa</a><br/> <anchor>提交anchor <go href="test_utf.php" method="post"> <postfield name="name" value="$(name:e)" /> </go> </anchor><br/> </p> </card> </wml>