Loading

邢栋博客

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

<?php //单例模式 class Singleton { /** * @var 这个类的"单例" */ private static $instance; /** * 防止在这个类之外new这个类 */ private function __construct() { } /** * @return 返回这个类的单例 */ public static function getInstance() { ...

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...