漂定

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::

随笔分类 -  PHP

1 2 下一页

PHP相关
摘要:'; const MYTT = 'aaa'; #print_r(get_defined_constants()); /* 5.4 新增短数组语法,比如 $a = [1, 2, 3, 4]; 或 $a = ['one' => 1, 'two' => 2, 'three' => 3, 'four' => 4]; 。 新增支持对函数返回数组的成员访问解析,例如 foo()[0] 。 现在 闭包 支... 阅读全文
posted @ 2016-12-15 17:22 漂定 阅读(1313) 评论(0) 推荐(0)

摘要:// 随机字符串 function random($length, $numeric = FALSE) { $seed = base_convert(md5(microtime() . $_SERVER['DOCUMENT_ROOT']), 16, $numeric ? 10 : 35); $seed = $numeric ? (str_replace('0', '', $see... 阅读全文
posted @ 2016-05-12 09:15 漂定 阅读(273) 评论(0) 推荐(0)

摘要:connect('127.0.0.1', 11211)) die('could not connect'); } if('' === $value){ return $cache->get($name); }elseif(is_null($value)) { return $cache->delete($name); }else ... 阅读全文
posted @ 2016-05-05 11:18 漂定 阅读(227) 评论(0) 推荐(0)

摘要:hasItem($id)){ $this->incCartNum($id,$num); return true; } $this->items[$id] = array( 'id' => $id, 'name' => $name, 'pr... 阅读全文
posted @ 2016-05-05 00:09 漂定 阅读(581) 评论(0) 推荐(0)

摘要:class CImage { /** * 生成保持原图纵横比的缩略图,支持.png .jpg .gif * 缩略图类型统一为.png格式 * $srcFile 原图像文件名称 * $toW 缩略图宽 * $toH 缩略图高 * $toFile 缩略图文件名称,... 阅读全文
posted @ 2016-03-29 16:16 漂定 阅读(275) 评论(0) 推荐(0)

摘要:MemcacheQ 是一个基于 MemcacheDB 的消息队列服务器。官网地址:http://memcachedb.org/memcacheq/特点:1.简单易用。2.处理速度快。3.可创建多条队列。4.并发性能高。5.与memcache协议兼容。MemcacheQ 依赖 Berkeley DB ... 阅读全文
posted @ 2015-05-05 14:07 漂定 阅读(227) 评论(0) 推荐(0)

摘要:PHP中的实现服务端服务端主要进行了以下步骤:创建Socket的监听,等待连接当链接到来时,开启一个子连接处理IO接收来自客户端的传输数据将结果写回给客户端 客户端客户端主要有以下步骤:连接到服务端Socket向服务端写数据接收来自服务端的数据 阅读全文
posted @ 2015-03-27 13:16 漂定 阅读(238) 评论(0) 推荐(0)

摘要:PHPWord(http://phpword.codeplex.com/)是一个很好处理和生成WORD文档的工具,但是生成复杂的word,如colspan和rowspan的实现,还是需要你做些修改。第一步:在phpword/Style/Cell.php文件类中添加如下属性:private $_gri... 阅读全文
posted @ 2015-03-25 18:35 漂定 阅读(5272) 评论(0) 推荐(0)

摘要:http://phpexcel.codeplex.com/下面是总结的几个使用方法include 'PHPExcel.php';include 'PHPExcel/Writer/Excel2007.php';//或者include 'PHPExcel/Writer/Excel5.php'; 用于输出... 阅读全文
posted @ 2015-03-23 09:00 漂定 阅读(1411) 评论(0) 推荐(0)

摘要:/** * 加密函数 * * @return string */ function wuEncrypt($sTxt,$sKey='PiihcIictI'){ $iKey = '_vr0Bo.psIFJ2flX3sgfk6g6Z2sG9gkRm'; $sChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrs... 阅读全文
posted @ 2014-11-14 21:36 漂定 阅读(357) 评论(0) 推荐(0)

摘要:2014 年10个最佳的PHP图像操作库Thomas Boutell 以及众多的开发者创造了以GD图形库闻名的一个图形软件库,用于动态的图形计算. GD提供了对于诸如C, Perl, Python, PHP, OCaml等等诸多编程语言的支持. 除了生成HTML输出之外, 你还可以使用php以众多的... 阅读全文
posted @ 2014-11-03 20:57 漂定 阅读(154) 评论(0) 推荐(0)

摘要:_/___.' >'"".// | | : `- \`.;`\ _ /`;.`/ - ` : | |// \ \ `-. \_ __\ /__ _/ .-` / ///======`-.____`-.___\_____/___.-`____.-'======// ... 阅读全文
posted @ 2014-09-17 09:32 漂定 阅读(189) 评论(0) 推荐(0)

摘要:模拟PHP Memcache 类。当服务器没有开启Memcache扩展的时候。可以采用本类使用方法class_exists('Memcache') or include './Memcache.class.php';$mem = new Memcache;$mem->add('key','value... 阅读全文
posted @ 2014-09-16 15:46 漂定 阅读(881) 评论(0) 推荐(0)

摘要:在抓取某网站数据,结果在数据包中发现了一串编码的数据:"......\u65b0\u6d6a\u5fae\u535a......", 这其实是中文被unicode编码后了的数据,想解码出中文来。解决方案:方案A(稳定版+推荐):function replace_unicode_escape_sequ... 阅读全文
posted @ 2014-08-18 10:07 漂定 阅读(1283) 评论(0) 推荐(0)

摘要:1 '0', '1'=>'1', '2'=>'2', '3'=>'3', '4'=>'4','5'=>'5', '6'=>'6', '7'=>'7', '8'=>'8', '9'=>'9', 13 'A'=>'A 阅读全文
posted @ 2014-02-12 16:56 漂定 阅读(382) 评论(0) 推荐(0)

摘要:#### 方案一:PHP 5.3 以上版本,使用pthreads PHP扩展,可以使PHP真正地支持多线程。多线程在处理重复性的循环任务,能够大大缩短程序执行时间。我之前的文章中说过,大多数网站的性能瓶颈不在PHP服务器上,因为它可以简单地通过横向增加服务器或CPU核数来轻松应对(对于各种云主机,增加VPS或CPU核数就更方便了,直接以备份镜像增加VPS,连操作系统、环境都不用安装配置),而是在于MySQL数据库。如果用 MySQL 数据库,一条联合查询的SQL,也许就可以处理完业务逻辑,但是,遇到大量并发请求,就歇菜了。如果用 NoSQL 数据库,也许需要十次查询,才能处理完同样地业务逻辑, 阅读全文
posted @ 2014-01-19 11:40 漂定 阅读(559) 评论(0) 推荐(0)

摘要: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 ?> 阅读全文
posted @ 2014-01-19 11:12 漂定 阅读(468) 评论(0) 推荐(0)

摘要: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 阅读全文
posted @ 2014-01-19 11:09 漂定 阅读(358) 评论(0) 推荐(0)

摘要: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 阅读全文
posted @ 2014-01-15 14:01 漂定 阅读(243) 评论(0) 推荐(0)

摘要:查询utf-8的编码规范最高字节0xxx xxxx , 1个字节110xx xxxx , 2个字节1110 xxxx, 3 3个字节1111 0xxxx 4... 4个字节......'; $res .= substr($str,$offset,$count); $chars += 1; $offset += $count; } return $res;}echo utf8sub($str,200);?> 阅读全文
posted @ 2013-12-25 10:35 漂定 阅读(238) 评论(0) 推荐(0)

1 2 下一页