摘要:1 /** 2 * 手机分辨率转化类 3 */ 4 package com.wu.mynews.util; 5 6 import android.content.Context; 7 8 public class DensityUtil { 9 10 /**11 * 根据手机的分辨率从 dp 的单位 转成为 px(像素)12 * @param context13 * @param dpValue14 * @return15 */16 public static int dip2px(Context contex...
阅读全文
01 2014 档案
摘要:#### 方案一:PHP 5.3 以上版本,使用pthreads PHP扩展,可以使PHP真正地支持多线程。多线程在处理重复性的循环任务,能够大大缩短程序执行时间。我之前的文章中说过,大多数网站的性能瓶颈不在PHP服务器上,因为它可以简单地通过横向增加服务器或CPU核数来轻松应对(对于各种云主机,增加VPS或CPU核数就更方便了,直接以备份镜像增加VPS,连操作系统、环境都不用安装配置),而是在于MySQL数据库。如果用 MySQL 数据库,一条联合查询的SQL,也许就可以处理完业务逻辑,但是,遇到大量并发请求,就歇菜了。如果用 NoSQL 数据库,也许需要十次查询,才能处理完同样地业务逻辑,
阅读全文
摘要:1 $keyword,'from'=>$from); 31 }32 33 //以下为测试 34 //在搜索引擎搜索个关键词,进入网站 35 $word = search_word_from(); 36 if(!empty($word['keyword'])){ 37 echo '关键字:'.$word['keyword'].' 来自:'.$word['from']; 38 } 39 ?>
阅读全文
摘要:1 <?php 2 /** 3 * 检测文件编码 4 * @param string $file 文件路径 5 * @return string|null 返回 编码名 或 null 6 */ 7 function detect_encoding($file) { 8 $list = array('GBK', 'UTF-8', 'UTF-16LE', 'UTF-16BE', 'ISO-8859-1'); 9 $str = file_get_contents($file);10 foreach ($list a
阅读全文
摘要:fp = fopen($filepath, 'rb'); //二制方式打开 $this->firstip = $this->get4b(); //第一条ip索引的绝对偏移地址 $this->lastip = $this->get4b(); //最后一条ip索引的绝对偏移地址 $this->totalip = ($this->lastip - $this->firstip) / 7; //ip总数 索引区是定长的7个字节,在此要除以7, register_shutdown_function(array($this, "close
阅读全文

浙公网安备 33010602011771号