归档于 四月, 2007

PHP写的javascript unescape解密函数

PHP写的javascript unescape解密函数 ——————————————————————————– 要求iconv函数可用(iconv扩展库已加载),这样可以直接对php里的值进行操作了。

php5.2 Json不能正确处理中文的解决办法

php5.2新增的json功能是非常受欢迎的,但是经过测试发现, json_encode对中文的处理是有问题的, 1.不能处理GB编码,所有的GB编码都会替换成空字符. 2.utf8编码的中文被编码成unicode编码,相当于javascript的escape函数处理的结果. 为了能正确使用json,首先我们就应该在编码上采用utf8编码,然后再对json_encode的返回结果稍加处理就可以得到正确的结果了。 我写了一个简单的类,将这两个函数包装了一下, class Json{ public static function encode($str){ $code = json_encode($str); return preg_replace(“#\\\u([0-9a-f]+)#ie”, “iconv(‘UCS-2′, ‘UTF-8′, pack(‘H4′, ‘\\1′))”, $code); } public static function decode($str){ return json_decode($str); } } 使用的时候 Json::encode($code); Json::decode($code); 这样可以正确处理utf8编码的中文了。 PS:对于GB编码的中文,我们可以在编码时先转成UTF8编码,再进行编码,解码的时候再进行一个utf8 -> gb的转换就可以了。这个就留给同学们自己练习一下了:)。 另外一般json_encode的结果我们是返回到客户端来使用,我们其实还可以用javascript的unescape函数来对unicode编码的中文进行解码,从而还原成正确的中文。

javascript+sound

soundmanagerv20b-20070201.zip

一堆AJAX代码

含mini AJAX IM SWF UPLOAD upload process bar swf.zip

php5.20+对php.ini的排序寻址顺序

http://www.php.net/manual/zh/configuration.php  Run php 4 and php 5.2.x on the same machine with IIS 6.0 as ISAPI. 1. Extract the ZIP packages of both php 4 & php 5 (not the Windows Installer) to c:\php4 & c:\php5 respectively 2. Setup the corresponding php.ini files in c:\php4 and c:\php5 3. Add the Web Service Extensions for php4 [...]