xcache也开始追求版本号了?
1.x的时候几年都没变。2.01刚发布3个月立刻就是3.0了?
虽然官网上说这是一个里程碑式的更新,但谁能说的清?
更新倒是不少:
API Changes
========
* chg: proto array xcache_clear_cache(int type, [ int id = -1 ]). -1 means all cache splits
* new: proto array xcache_enable_cache(int type, [ int id = -1, [ bool enable = true ] ])
* new: proto array xcache_admin_namespace()
* new: proto array xcache_set_namespace(string namespace)
Ini Settings Changes
========
* new: xcache.disable_on_crash = Off
* new: xcache.coverager_autostart = On
* new: xcache.allocator = bestfit (no other option value yet)
* new: xcache.var_allocator = bestfit (no other option value yet)
ChangeLog
========
* closes #2: auto disable caching on crash
* closes #73: warn for improper PHP_FCGI_CHILDREN setting fcgi mode (>=PHP_5_3)
* closes #174: updates api to support "clear all cache"
* closes #198: support for caching protocol url
* closes #287: namespace support
* fixes #39: ini_set never work for xcache.coverager setting. use API instead
* code refactor
* uses extension= to load XCache. loading via zend_extension= is unsupported
* split XCache features into multiple sub modules
* updates XCache admin page
* adds an diagnosis module to give professional advise, accessable via htdocs pages
* cache can be enabled/disabled manually
反正,他们自我评价挺高的:XCache 3.0.0 released. Lots of improvements, bug fixes. This is a big new milestone refactoring most XCache code.
在首页的下载里面还写着:
2.1.x, unstable, devel, features
结果,3.0都Release了。。。
这年头。。。还能怎么办?
这篇文章又能当成开发文档,也能当成软文,所以,你们就将就着看吧。
yii框架中很早就支持路由功能了。所以,从那时候开始,很多人就开始将项目路由化,举例说明:
http://user.pinjian.net,访问用户中心
http://admin.pinjian.net 访问后台
http://xxxx.pinjian.net 访问Xxx
表面上这是一大堆 网站,其实很有可能是什么?只是一个控制器或者一个module罢了。
http://user.pinjian.net可能对应了什么?http://pinjian.net/user/index,很有可能就这样而已。
而对于yii来说,这个太简单了
在main.php(环境 变量设置中),针对urlManager的rules加入:
PHP代码
- 'urlManager' => array(
- 'urlFormat' => 'path',
- 'showScriptName'=>false,
- 'rules' => array(
- 'http://photo.pinjian.net/<action:\w+>'=>'image/<action>',
- '<controller:\w+>/<id:\d+>' => '<controller>/view',
- '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
- '<controller:\w+>/<action:\w+>' => '<controller>/<action>',
- ),
- ),
看看高亮的那一行,是不是很简单?
之前,有一篇博客介绍过的:http://www.neatstudio.com/show-1550-1.shtml,还篇比较详细
其实只是一段很少的代码。
http://www.kalvin.cn/article/php-encrypt-decrypt-unicode-string-functions-and-escape/
- <?php
- function uni_decode($s) {
- preg_match_all('/\&\#([0-9]{2,5})\;/', $s, $html_uni);
- preg_match_all('/[\\\%]u([0-9a-f]{4})/ie', $s, $js_uni);
- $source = array_merge($html_uni[0], $js_uni[0]);
- $js = array();
- for($i=0;$i<count($js_uni[1]);$i++) {
- $js[] = hexdec($js_uni[1][$i]);
- }
- $utf8 = array_merge($html_uni[1], $js);
- $code = $s;
- for($j=0;$j<count($utf8);$j++) {
- $code = str_replace($source[$j], unicode2utf8($utf8[$j]), $code);
- }
- return $code;
- }
-
- function unicode2utf8($c) {
- $str="";
- if ($c < 0x80) {
- $str.=chr($c);
- } else if ($c < 0x800) {
- $str.=chr(0xc0 | $c>>6);
- $str.=chr(0x80 | $c & 0x3f);
- } else if ($c < 0x10000) {
- $str.=chr(0xe0 | $c>>12);
- $str.=chr(0x80 | $c>>6 & 0x3f);
- $str.=chr(0x80 | $c & 0x3f);
- } else if ($c < 0x200000) {
- $str.=chr(0xf0 | $c>>18);
- $str.=chr(0x80 | $c>>12 & 0x3f);
- $str.=chr(0x80 | $c>>6 & 0x3f);
- $str.=chr(0x80 | $c & 0x3f);
- }
- return $str;
- }
-
- $str='%u5927%u5BB6%u597D%uFF0C我是孤魂!<br />\u8FD9\u662F\u6D4B\u8BD5\u6587\u672C\uFF01';
- echo uni_decode($str);
- ?>
这段代码以前也写过,而且,其实用的地方挺多,比如json的字符串(有些只是json处理了一下,但并不能完全转换,总不能强制变成json格式再转换吧?)
其实黑的很方便,而且这段代码在PHP手册中的注释里也出现过,但一下子找不到了,于是看到后就做了个备份罢了
在项目中遇到点小问题。。。
比如:1.4.0与1.4.1对比。还有1.2与1.21对比
在初期的时候,我都是直接使用version_compare来对比的,但这时候就出现了问题
在国人眼中,1.21其实是1.2的后续版本,它是比1.3小的一个版本。但。。。version_compare即不认的。它认为1.21>1.2,当然1.21也>1.3。。。
好纠结啊。。。
后面没办法,对于1.4.0这种用version_compare了。对于1.21的,直接浮点数来比较了。NND
以后对版本号还是需要有一个规划,不能乱写啊
利用php的curl库上传文件真的很方便
注意几点
1、只能是POST
2、可以不写头(平时的form有文件和无文件时发送的时候,)
3、postfields的时候,不要你傻傻的http_build_query,你越是这么做了。黑黑。。。就反而不一定对了
4、上传的文件用@来连接。
一个很小的例子
PHP代码
- $formAction = 'http://xxx/xxx/xx.upload.php';
- $postVals = array(
-
-
- 'img'=>'@/var/www/xxx.jpg',
-
- );
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $formAction);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, ($postVals));
- $res = curl_exec($ch);
- curl_close($ch);
看看多简单,一下子就成功了