随笔分类 -  PHP

摘要:观察者模式是非常有用的设计模式,事件机制,发布订阅等都是基于观察者模式实现的。 观察者模式顾名思义要有“观察者”和“被观察者”,为了约束两者的行为,又需要各自的接口(Interface)。我们来实现一个Demo: ObserverInterface.php <?php /** * Interface 阅读全文
posted @ 2020-08-21 11:13 yikai.shao 阅读(157) 评论(0) 推荐(0)
摘要:基本格式 * * * * * command 分 时 日 月 周 命令 第1列表示分钟1~59 每分钟用*或者 */1表示 第2列表示小时1~23(0表示0点) 第3列表示日期1~31 第4列表示月份1~12 第5列标识号星期0~6(0表示星期天) 第6列要运行的命令 crontab文件的一些例子: 阅读全文
posted @ 2017-03-06 21:23 yikai.shao 阅读(172) 评论(0) 推荐(0)
摘要:核心用到的是mb_convert_encoding函数,示例代码如下: 参考文档:https://gist.github.com/welefen/7746175 阅读全文
posted @ 2016-07-13 18:01 yikai.shao 阅读(2109) 评论(0) 推荐(0)
摘要:方式一:diff($datetime2)->format('%R%a'));}echo days(2015,1)."";echo days(2015,2)."";echo days(2015,3)."";echo days(2015,4)."";echo days(2015,5)."";echo d... 阅读全文
posted @ 2015-12-01 16:52 yikai.shao 阅读(985) 评论(0) 推荐(0)
摘要:拉取wordpress镜像docker pull wordpress:latest创建mysql 容器docker run --name wordpress-mysql -e MYSQL_ROOT_PASSWORD=root -d mysql:latest创建wordpress容器并link上一步创... 阅读全文
posted @ 2015-09-06 15:31 yikai.shao 阅读(242) 评论(0) 推荐(0)
摘要:<?phpecho make_random_str();function make_random_str(){ $arr = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q&q 阅读全文
posted @ 2015-06-04 20:03 yikai.shao 阅读(169) 评论(0) 推荐(0)
摘要:直接上代码:$db = Yii::$app->db;$transaction = $db->beginTransaction(); //开启事务try { // 更新member表 $db->createCommand()->update('member',[ 'level' ... 阅读全文
posted @ 2015-05-29 14:21 yikai.shao 阅读(473) 评论(0) 推荐(0)
摘要:作为PHP工程师,经常需要输出一下变量,以便检验程序是否正确,如:var_dump($var);exit;可是,每次这么写也太麻烦了,我们可以在程序的入口文件index.php中编写一个函数function ddd($param,$mark=false){ if($mark){ ... 阅读全文
posted @ 2015-05-29 14:10 yikai.shao 阅读(149) 评论(0) 推荐(0)
摘要:文件hello.php和index.php在同一目录hello.php [2] => class hello{ [3] => [4] => public function __construct() [5] => { [6] => ... 阅读全文
posted @ 2015-05-11 11:44 yikai.shao 阅读(720) 评论(0) 推荐(0)
摘要:举个例子就可以看懂了: 同一目录中有2个文件index.php和test.php,在test.php中定义一个test类。 test.php index.php 尽管 __autoload() 函数也能自动加载类和接口,但更建议使用 spl_autoload_register() 函数。 spl_a 阅读全文
posted @ 2015-05-11 09:20 yikai.shao 阅读(245) 评论(0) 推荐(0)
摘要:今天遇到一个很诡异的问题:数据库中存的日期信息为时间戳,用php取出数据库中的日期信息,并用date()函数转化为“Y-m-d”后,发现和mysql格式化函数Date_Format()处理后的结果不一致,总是少一天。这个问题导致程序中隐藏的bug,费了我好大劲,最后一步步调试,才最终发现是日期不一致... 阅读全文
posted @ 2015-04-29 17:28 yikai.shao 阅读(209) 评论(0) 推荐(0)
摘要:Installing Pre-RequisitesNote that RRDTool 1.0.x versions included all dependancies, but 1.2.x versions require you to install these dependancies befo... 阅读全文
posted @ 2015-04-01 18:30 yikai.shao 阅读(812) 评论(0) 推荐(0)
摘要:GD库的安装sudo apt-get install php5-gdsudo apt-get install php5-gd sudo /etc/init.d/apache2 restartCURL安装sudo apt-get install php5-curl 阅读全文
posted @ 2015-04-01 10:10 yikai.shao 阅读(347) 评论(1) 推荐(0)
摘要:背景介绍:LAMP开发是很多公司喜欢采用的技术组合,故而做php开发,使用linux环境也是很多公司的要求。本文就来介绍下如何在windows下,使用phpstorm集成开发环境,来开发放在linux虚拟机的PHP项目。环境介绍:win7系统,phpstorm,虚拟主机ubuntu-server版。... 阅读全文
posted @ 2015-03-31 17:59 yikai.shao 阅读(12934) 评论(2) 推荐(1)
摘要:PHP史诗级IDE,你懂的…… 阅读全文
posted @ 2015-03-28 12:28 yikai.shao 阅读(269) 评论(1) 推荐(0)
摘要:codegigniter框架多语言的实现 阅读全文
posted @ 2015-01-09 10:20 yikai.shao 阅读(878) 评论(1) 推荐(0)
摘要:xdebug调试工具的配置 阅读全文
posted @ 2014-12-30 14:25 yikai.shao 阅读(421) 评论(1) 推荐(0)
摘要:文件缓存的使用和弊端 阅读全文
posted @ 2014-12-30 10:34 yikai.shao 阅读(178) 评论(2) 推荐(0)
摘要:PHP5.5整合了zend opcache,但是5.4以下的需要自己安装。介绍一下开启opcache方法,环境为wamp(php5.4.16)下载dll文件把php_opcache.dll放进php/ext目录配置php.inizend_extension = "c:/wamp/bin/php/ph... 阅读全文
posted @ 2014-12-12 13:43 yikai.shao 阅读(717) 评论(0) 推荐(0)
摘要:Apache、Mysql、PHP单独安装(for Windows) 阅读全文
posted @ 2014-12-10 15:51 yikai.shao 阅读(247) 评论(0) 推荐(0)