特点&应用:
- 适合制作API文档、介绍手册/说明文档、数据字典等;
- 免费开源;
- 基于thinkphp;
- 支持markdown语法;
- 支持多项目;
- 可免费使用官方在线版,也可部署在自己的服务器上使用
- 等等
足迹,留给未来的自己
【摘自:http://blog.csdn.net/fgdfgasd/article/details/42005041】
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
/** * 获取指定月份的第一天开始和最后一天结束的时间戳 * * @param int $y 年份 $m 月份 * @return array(本月开始时间,本月结束时间) */ function mFristAndLast($y="",$m=""){ if($y=="") $y=date("Y"); if($m=="") $m=date("m"); $m=sprintf("%02d",intval($m)); $y=str_pad(intval($y),4,"0",STR_PAD_RIGHT); $m>12||$m<1?$m=1:$m=$m; $firstday=strtotime($y.$m."01000000"); $firstdaystr=date("Y-m-01",$firstday); $lastday = strtotime(date('Y-m-d 23:59:59', strtotime("$firstdaystr +1 month -1 day"))); return array("firstday"=>$firstday,"lastday"=>$lastday); } |
ziadoz 在 Github 发起维护的一个 PHP 资源列表,内容包括:库、框架、模板、安全、代码分析、日志、第三方库、配置工具、Web 工具、书籍、电子书、经典博文等等。
链接:https://github.com/ziadoz/awesome-php
翻译:http://blog.jobbole.com/82908/
[导读] 在php中我们经常使用写一些简单的采集功能,这样可以自动把远程服务器的图片或资源直接采集保存到本地服务器中,下面我来给大家详细介绍远程图片并把它保存到本地几种方法。例1 代码如下
在php中我们经常使用写一些简单的采集功能,这样可以自动把远程服务器的图片或资源直接采集保存到本地服务器中,下面我来给大家详细介绍远程图片并把它保存到本地几种方法。例1
代码如下 | |
/* *功能:php多种方式完美实现下载远程图片保存到本地 *参数:文件url,保存文件名称,使用的下载方式 *当保存文件名称为空时则使用远程文件原来的名称 */ function getImage($url,$filename=”,$type=0){ if($url==”){return false;} if($filename==”){ $ext=strrchr($url,’.’); if($ext!=’.gif’ && $ext!=’.jpg’){return false;} $filename=time().$ext; } //文件保存路径 if($type){ $ch=curl_init(); $timeout=5; curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout); $img=curl_exec($ch); curl_close($ch); }else{ ob_start(); readfile($url); $img=ob_get_contents(); ob_end_clean(); } $size=strlen($img); //文件大小 $fp2=@fopen($filename,’a’); fwrite($fp2,$img); fclose($fp2); return $filename; } |
背景:使用linux服务器(centos);
前提:使用ssh 登录服务器;
操作:按以下提示执行命令。
一、 下载安装libevent
执行以下命令下载:
1 |
wget https://sourceforge.net/projects/levent/files/libevent/libevent-2.0/libevent-2.0.22-stable.tar.gz --no-check-certificate |
分别执行以下命令解压安装:
1 |
tar -zxvf libevent-2.0.22-stable.tar.gz |
1 |
cd libevent-2.0.22-stable |
1 |
./configure --prefix=/usr/local |
1 |
make & make install |
1 |
ls -al /usr/local/lib | grep libevent |
退回主目录:
1 |
cd ~ |
执行以下命令下载:
1 |
wget http://memcached.org/files/memcached-1.4.24.tar.gz |
执行以下命令解压安装:
1 |
tar -zxvf memcached-1.4.24.tar.gz |
1 |
cd memcached-1.4.24 |
1 |
./configure –with-libevent=/usr/local |
1 |
make & make install |
执行以下命令测试是否安装成功,若如截图所示,则安装成功:
1 |
ls -al /usr/local/bin/memcached |
退回主目录:
1 |
cd ~ |
执行以下命令下载:
1 |
wget http://pecl.php.net/get/memcache-3.0.8.tgz |
执行以下命令解压安装:
1 |
tar -zxvf memcache-3.0.8 |
1 |
cd memcache-3.0.8 |
查询服务器文件phpize路径:
1 |
find / -name phpize |
在memcache-3.0.8目录下,执行以下命令:
1 |
/alidata/server/php-5.4.27/bin/phpize |
查询服务器文件php-config路径:
1 |
find / -name php-config |
1 |
./configure –enable-memcache –with-php-config=/alidata/server/php-5.4.27/bin/php-config –with-zlib-dir |
最后执行以下命令完成安装memcache,
1 |
make & make install |
若以上执行结果最后部分是以下截图内容,则安装成功:
通过浏览器查看服务器的phpinfo内容,找到php.ini文件路径,如下图,
使用VIM编辑此文件,在文件最后,新增以下内容,
1 2 3 4 5 |
extension=memcache.so [Memcache] memcache.allow_failover = 1 memcache.max_failover_attempts=20 memcache.chunk_size =8192 |
重启Apache,再次查看phpinfo信息内容,若存在以下内容,则配置成功,
1 |
memcached -d -m 1024 -u root -l 127.0.0.1 -p 11211 -c 256 -P /tmp/memcached.pid |
(注: 可将127.0.0.1 替换成自己服务器的外网IP)
(PS,若以上命令无法启动memcache,尝试忽略最后的-P 参数信息。)
执行以下命令,若结果如截图所示,则启动成功:
1 |
netstat –ant |
(注:执行以下命令,结束memcache服务)
1 |
kill cat /tmp/memcached.pid |
eAccelerator是一个开源php加速,优化和动态内容缓存,提高了性能php脚本的缓存性能,使得PHP脚本在编译的状态下,对服务器的开销几乎完全消除。它还有对脚本起优化作用,以加快其执行效率。使PHP代码执行效率能提高1-10倍。
版本比较:
eaccelerator 0.9.5.3 只支持php 5.2.x版本,支持数据缓存;
eaccelerator 0.9.6.1 只支持php 5.3.x版本,只对PHP做加速处理;
eaccelerator 1.0 dev 只支持php 5.4.x版本,只对PHP做加速处理。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
<?php header('Content-Type: text/html; charset=utf-8');?> <style> ul {list-style-type: circle} </style> <?php $array = array( "苹果" => array ( "一代" => array( "苹果1", "苹果1S" ), "二代" => array( "苹果2", array( "苹果2 8G","苹果2 16G" ), ), "三代" => array() ), "三星" => array( "galaxy S4", "galaxy S5" ), ); class RecursiveListIterator extends RecursiveIteratorIterator { public $tab = "t"; public function beginChildren() { if (count($this->getInnerIterator()) == 0) { return; } echo str_repeat($this->tab, $this->getDepth()), "<ul>n"; } public function endChildren() { if (count($this->getInnerIterator()) == 0) { return; } echo str_repeat($this->tab, $this->getDepth()), "</ul>n"; echo str_repeat($this->tab, $this->getDepth()), "</li>n"; } public function nextElement() { // 显示叶子节点 if ( ! $this->callHasChildren()) { echo str_repeat($this->tab, $this->getDepth()+1), '<li>', $this->current(), "</li>n"; return; } // 显示分支标签 echo str_repeat($this->tab, $this->getDepth()+1), '<li>', $this->key(); echo (count($this->callGetChildren()) == 0) ? "</li>n" : "n"; } } $it = new RecursiveListIterator(new RecursiveArrayIterator($array), RecursiveIteratorIterator::SELF_FIRST); echo "<ul>n"; foreach($it as $key => $item); echo "</ul>n"; |
转载自:http://www.hiceon.com/topic/zhuiye-recursiveiteratoriterator/
近日在对ECStore进行系统集群部署的过程中,由于开发环境使用的是X64的CentOS系统,而在测试虚拟集群中使用X86的CentOS系统。部署后发现很多功能都存在问题,包括widget、商品附加属性等都无法正常显示,通过代码回溯发现,在数据库中存储的序列化数据在系统中进行反序列化会返回false。
在64位系统中
其实在将含有大整形数值的数组变为字符串的方法中基本都存在类似的问题,例如JSON_DECODE也会因为位元问题导致解码失败,这个问题估计要比序列化更为严重,因为目前流行的webservice中,尤其是RESTFUL所用到数据格式是JSON,如果在位元不同的混杂系统环境下,就可能会导致无法正确解析数据的问题。
在PHP 5.4+中,该问题得到了有效的解决。你可以使用json_decode的第四个参数来将大整数作为字符串进行解析。如下:
1 |
json_decode($json, false, 512, JSON_BIGINT_AS_STRING) |
转载自:http://www.hiceon.com/topic/the-x86-and-x64-system-of-the-php-serialize-and-unserialize-discrepancies/
https://app.loadimpact.com