Loading

邢栋博客

php设计模式之工厂模式简单事例

<?php //工厂模式 class Automobile { private $vehicleMake; private $vehicleModle; public function __construct($make,$model) { $this->vehicleMake = $make; $this->vehicleModle = $model; } public function getMakeAndModel() { ...

shell脚本下执行sql语句

vim mysql.sh #!/bin/bash host='127.0.0.1' user='root' passwd='root' dbname='test' test_sql='select count(*) from test' num=$(mysql -s -h$host -u$user -p$passwd $dbname -e "$test_sql") echo $num

php-fpm重启、启动、停止命令

启动php-fpm: /usr/local/php/sbin/php-fpm php-fpm需要使用信号控制,master进程可以理解以下信号 INT, TERM 立刻终止 QUIT 平滑终止 USR1 重新打开日志文件 USR2 平滑重载所有worker进程并重新载入配置和二进制模块 重启方法1 先查看php-fpm的master进程号 ps aux|grep php-fpm 然后 kill -USR2 进程号 重启方法2 cat /usr/local/php/etc/php-fpm.conf 找到对应的php-fpm.pid ...

使用shell脚本每秒执行一次php程序

vim test.sh #!/bin/bash step=1 #间隔的秒数,不能大于60 for (( i = 0; i < 60; i=(i+step) )); do $(/work/software/php/bin/php '/work/www/live/test.php') sleep $step done exit 0

php关于猴子选大王的算法题

<?php /** * $m 猴子总数 * $n 出局数 */ function king($m,$n){ $arr = range(1, $m); $i = 0; while (count($arr)>1) { if(($i+1)%$n == 0){ unset($arr[$i]); }else{ array_push($arr, $...

redis查看当前redis-server启动使用的配置文件

redis查看当前redis-server启动使用的配置文件 redis-cli info | grep config

mongo提示Cannot natively represent the long 1476355233494 on this platform

今天用rockmongo打开一个集合的时候提示 Cannot natively represent the long 1476355233494 on this platform 解决办法 在index.php中加入 ini_set('mongo.long_as_object', 1);

php还原java中gzip压缩方法

有个需求,要把java代码里面的jzip压缩方法还原成php java jzip压缩代码如下 /*** * 压缩GZip * * @param data * @return */ public static byte[] gZip(byte[] data) { byte[] b = null; try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ...

windows下把redis加入服务

加入服务,开机自启动 redis-server.exe --service-install redis.windows.conf 启动 redis-server.exe --service-start 停止 redis-server.exe --service-stop 卸载 redis-server.exe --service-uninstall 安装多个实例 redis-server.exe --service-install –service-name redisService1 –port 10001 redis-server.exe --ser...

了解 Linux中Buffer和Cache

Buffer和Cache的区别 buffer与cache操作的对象就不一样。 buffer(缓冲)是为了提高内存和硬盘(或其他I/O设备)之间的数据交换的速度而设计的。 缓冲(buffers)是根据磁盘的读写设计的,把分散的写操作集中进行,减少磁盘碎片和硬盘的反复寻道,从而提高系统性能。linux有一个守护进程定期清空缓冲内容(即写入磁盘),也可以通过sync命令手动清空缓冲。 简单来说,buffer是即将要被写入磁盘的,而cache是被从磁盘中读出来的。 buffer是由各种进程分配的,被用在如输入队列等方面。一个简单的例子如某个进程要求有多个字段读入...