随笔分类 -  PHP

摘要:java 服务端测试代码: @Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { buffer.writeShort(5); buff 阅读全文
posted @ 2020-10-02 15:40 ﹏Sakura 阅读(533) 评论(0) 推荐(0)
摘要:<?php $str = "pwwke121w"; $existMap = []; $longest = 0; for( $j=0, $i=0; $j < strlen($str); $j++ ){ $char = $str[$j]; $i = max($i , $existMap[$char]?? 阅读全文
posted @ 2020-09-16 11:18 ﹏Sakura 阅读(158) 评论(0) 推荐(0)
摘要:<?php class Graph{ private $data = []; const INFINITY = -1; public function addDirection( $fromNode, $toNode,$cost ){ if( !isset($this->data[$fromNode 阅读全文
posted @ 2020-08-31 16:34 ﹏Sakura 阅读(368) 评论(0) 推荐(0)
摘要:<?php class BFSearch{ public $pic = []; private $searchQueue = null; public function setPic( $pic ){ $this->pic = $pic; } public function find( $from 阅读全文
posted @ 2020-08-10 10:29 ﹏Sakura 阅读(150) 评论(0) 推荐(0)
摘要:主要为方便单用户请求日志回溯分析 记录用户标记。 将用户信息打印在access_log 日志里。 步骤: 1、重写nginx 的log格式 一般是地址是 /etc/nginx/conf.d/nginx_log_format.conf 自定义需要记录的字段 相关官方信息: $upstream_http 阅读全文
posted @ 2019-08-01 16:46 ﹏Sakura 阅读(2339) 评论(0) 推荐(0)
摘要:class Lock { const PREFIX_KEY = "MY_LOCK:"; static private $LOCKED = []; static public function tryLock($key, $expire = 300) { $lock = self::PREFIX_KEY.$key; ... 阅读全文
posted @ 2018-01-18 17:20 ﹏Sakura 阅读(448) 评论(0) 推荐(0)
摘要:因php 语言特性(短链接), 没法实现共享内存来提升性能。 apc的出现给出了一个解决方案 。不过很可惜5.5+以后PHP官方已经废弃掉这个扩展。 幸好出现了 apcu扩展提供后续功能 api 也没有改变。所以PHP版本可以实现平滑升级。 官方下载地址:http://pecl.php.net/pa 阅读全文
posted @ 2017-12-21 11:26 ﹏Sakura 阅读(831) 评论(0) 推荐(0)
摘要:N久没面试了,尤其没做过题。今天正好碰到, 要求手写 ,写的比较凌乱 最后只聊了下思路 代码大概就这样了。。 阅读全文
posted @ 2017-11-19 14:44 ﹏Sakura 阅读(949) 评论(0) 推荐(0)
摘要:function buildXml( $data, $wrap= 'xml' ){ $str = ""; if( is_array( $data ) ){ if( hasIndex( $data ) ){ foreach( $data as $k=>$v ){ $str .= buildX... 阅读全文
posted @ 2017-05-27 11:09 ﹏Sakura 阅读(921) 评论(0) 推荐(0)
摘要:class A{ public $b; public $f; function __construct( B $b , $f = 1 ){ $this->b = $b; $this->f = $f; } } class B{} class GenClass{ public function getObj... 阅读全文
posted @ 2017-05-12 17:58 ﹏Sakura 阅读(807) 评论(0) 推荐(0)
摘要:好久没配置环境今天安装PHP 开发环境, 项目比较老,一开始以为项目用的是memcache 装完后发现 项目用的是memcached 所以正好两个都装了。 碰到些坑希望能帮助到百度到这篇文章的伙伴 。 一、首先区分memcache 和memcached 请注意这是两个完全不同的扩展 具体差异 请自行 阅读全文
posted @ 2017-04-10 16:20 ﹏Sakura 阅读(1789) 评论(0) 推荐(0)
摘要:/** * @author xiaojiang * 方式1 */ class father{ static $models = []; static public function getInstance(){ $name = get_called_class(); if( !isset( self::$models[$name] ) ){... 阅读全文
posted @ 2016-12-06 11:12 ﹏Sakura 阅读(3009) 评论(0) 推荐(0)
摘要:当用mssql存储数据采用 nchar 或 nvarchar 存储时 , 由于nchar 或 nvarcha 不支持 UCS-2 ( 即 SQLServer 不会按照 UTF-8 格式存储) 导致PHP 获取后会出现乱码 具体表现为: 汉字会变成???? 这种 而且没有提供类似 mysql_quer 阅读全文
posted @ 2016-12-01 12:55 ﹏Sakura 阅读(4996) 评论(0) 推荐(1)
摘要:./configure -prefix=/usr/local/php -with-config-file-path=/etc -with-mysql=mysqlnd -with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd -with-iconv-dir=/usr/ 阅读全文
posted @ 2016-09-23 16:41 ﹏Sakura 阅读(441) 评论(0) 推荐(0)
摘要:‘./configure’ ‘–prefix=/usr/local/php’ ‘–with-config-file-path=/etc’ ‘–with-mysql=/usr/local/mysql’ ‘–with-mysqli=/usr/local/mysql/bin/mysql_config’ ‘ 阅读全文
posted @ 2016-06-26 16:55 ﹏Sakura
摘要:No candidate servers found Thrown when the driver cannot establish a connection to MongoDB (fulfilling the ReadPreferences, if specified). No candidat 阅读全文
posted @ 2016-05-27 14:12 ﹏Sakura 阅读(1462) 评论(1) 推荐(0)
摘要:Query Builder $rows = (new \yii\db\Query()) ->select(['dyn_id', 'dyn_name']) ->from('zs_dynasty') ->where(['between','dyn_id', 1,30]) ->limit(10) ->all(); print_r($rows); use yii... 阅读全文
posted @ 2016-05-18 11:38 ﹏Sakura 阅读(2602) 评论(0) 推荐(0)
摘要:MongoAr.php MongoModel.php 阅读全文
posted @ 2016-04-15 17:04 ﹏Sakura 阅读(515) 评论(0) 推荐(0)
摘要:  阅读全文
posted @ 2016-03-14 18:35 ﹏Sakura 阅读(780) 评论(0) 推荐(0)
摘要:zero-lengthkeysarenotallowed,did you use $withdouble quotes?update操作,新的数组是一个二维数组,比如 array('$set'=>array('a'=>1));但是实际情况是 array(''=>array('a'=>1));就报这个... 阅读全文
posted @ 2015-12-22 16:03 ﹏Sakura 阅读(598) 评论(0) 推荐(0)