摘要: /** * 支持数组方式递归转换的iconv * @author Wilson Zeng | wilsonzeng@ppstream.com | jackzcs@gmail.com * @param unknown_type $inCharset * @param unknown_type $ou... 阅读全文
posted @ 2013-03-05 14:14 重生 阅读(431) 评论(1) 推荐(0) 编辑
摘要: //格式化为:{n}GB{n}MB{n}KB的样式function formatByteSize($bytes) { $format = $bytes . 'B'; foreach (array(1 => 'KB', 2 => 'MB', 3 => 'GB') as $exp => $unit) { $base = pow(1024, $exp); if ($bytes > $base) { $format = number_format($bytes / $base, 2) . $unit; con 阅读全文
posted @ 2012-11-21 11:13 重生 阅读(251) 评论(0) 推荐(0) 编辑
摘要: 1 //参考 http://w3.org/International/questions/qa-forms-utf-8.html 2 function is_utf8($string) { 3 return preg_match('%^(?: 4 [\x09\x0A\x0D\x20-\x7E] ... 阅读全文
posted @ 2012-02-29 18:14 重生 阅读(455) 评论(0) 推荐(0) 编辑
摘要: 我也是前段时间才接触到nodejs,感觉写起来挺爽的,大致学了下,就自己顺手写个简单(准确应该说是简陋)的MVC框架,当是练习了。 废话不多说,直接开上。 0.整体目录结构 大致说下,run.js是服务器监听入口,通过命令“node run”就可以开启服务了,server.js是HTTP服务器的创... 阅读全文
posted @ 2012-02-08 18:33 重生 阅读(4776) 评论(0) 推荐(1) 编辑
摘要: function test() { static $test; $test++; echo($test . " "); unset($test); $test = 2; echo($test . " ");}test();test();test(); 结果: 1 2 2 2 3 2 我是这样理解... 阅读全文
posted @ 2012-02-07 18:31 重生 阅读(4288) 评论(0) 推荐(0) 编辑
摘要: /** * wrap javascript codes with a html-tag * @author Wilson Zeng */function js($script){ return '<script type="text/javascript">'."\n".$script."\n".'</script>'."\n";}/** * wrap javascript codes with a html-tag & history back * 阅读全文
posted @ 2012-01-17 13:57 重生 阅读(158) 评论(0) 推荐(0) 编辑
摘要: /** * Like end(),return the first element of an array * @author Wilson Zeng */function first($stack){ if(is_array($stack)){ reset($stack); return current($stack); }else{ return $stack; }} 阅读全文
posted @ 2012-01-17 13:31 重生 阅读(105) 评论(0) 推荐(0) 编辑
摘要: /** * Enhanced force_download, can accept file in server * @author Wilson Zeng * @param $filename | The name that will use as the download file's nam... 阅读全文
posted @ 2012-01-17 13:30 重生 阅读(1206) 评论(0) 推荐(0) 编辑
摘要: /** * Enhanced file_get_contents, use curl to fetch remote file * @param $file * @author Wilson Zeng */function ex_file_get_contents($file){ //if is ... 阅读全文
posted @ 2012-01-17 13:28 重生 阅读(281) 评论(0) 推荐(0) 编辑
摘要: /** * Enhanced trim() to support array * @author Wilson Zeng */function exTrim($mixed, $removeEmptyString = FALSE){ if(is_array($mixed)){ foreach($mixed as $index => &$item){ $item = exTrim($item); if($removeEmptyString && $item === ''){ array_splice($mixed, $index, 1); ... 阅读全文
posted @ 2012-01-17 12:05 重生 阅读(203) 评论(0) 推荐(0) 编辑