Oct262019
php.ini配置php auto_prepend_file和auto_append_file参数
在 php.ini 中有两个配置参数,auto_prepend_file 和 auto_append_file,其作用相当于php代码 require 或 include,使用这两个指令包含的文件如果该文件不存在,将产生一个警告。
auto_prepend_file 表示在php程序加载应用程序前加载指定的php文件
auto_append_file 表示在php代码执行完毕后加载指定的php文件
在某些场合下我们可能要对所有的代码在执行前或者执行后进行统一处理,这时...阅读全文
作者:绝缘体.. | 分类:apache, nginx, PHP, windows, 开发工具, 操作系统, 编程语言 | 阅读: | 标签:Apache, nginx, PHP, windows, 文件
抢沙发
Oct242019
PHP获取以字母递增为键值的数组
PHP获取以字母递增为键值的数组。
/**
* 获取以字母递增为键值的数组
* @param bool $capitalization
* @param int $length
* @return array
*/
function getCharList($capitalization = true, $length = 26) {
$key = $capitalization ? 65/*大写字母*/ : 97/*小写字母*/;
$list = array();
for ($i = 1; $i <= $length; $i++) {
$list[] = chr($key);
...阅读全文
Oct232019
PHP与RabbitMQ消息队列
RabbitMQ提供跨语言接口,我们可以使用主流编程语言Java,C,C++,Python,PHP等和RabbitMQ做对接。RabbitMQ有消息确认机制、灵活的路由控制、以及消息集群高可用,使得很多大型系统使用RabbitMQ做消息处理系统。
消息队列(Message Queue)是一种应用间的通信方式,消息发送后可以立即返回,由消息系统来确保消息的可靠传递。消息发布者只管把消息发布到 MQ 中而不用管谁来取,消息使用者...阅读全文
Oct212019
如何获取监听iframe src属性的改变事件
应用场景,当iframe内发生点击事件内容改变时,如果我们想获取变化后的iframe的 src 属性值,根据相应的 src 值做一些特殊处理。这里我们就可以使用如下方式去获取:
<iframe src="http://www.phpernote.com/" onload="loadFrame(this)"></iframe>
<script type="text/javascript">
function loadFrame(obj) {
var url = obj.contentWindow.location.href...阅读全文
Oct212019
使用 php 实现类似 linux crontab 的定时任务功能,支持秒级定时
使用 php 实现类似 linux crontab 的定时任务功能,支持秒级定时任务类
/**
* Class Crontab
* description: 使用 php 实现类似 linux crontab 的定时任务功能,支持秒级定时
* author: http://www.phpernote.com/
*/
class Crontab {
/**
* 判断某个时间点是否在 cron 规则之内
* @param $cron
* @param $time
* @return bool
*/
public static f...阅读全文
Oct202019
laravel ide-helper安装
首先需要在phpStorm中安装laravel plugin:
接下来
引入此包,该命令会自动修改 composer.json 文件
composer require barryvdh/laravel-ide-helper
下载完成后加入 config/app.php 中的 providers 数组中
Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
仅在开发系统中安装提示包
composer require --dev barryvdh/laravel-ide-helper
在 app/Providers/AppServiceProvid...阅读全文
Oct162019
Git常用命令总结(缩减GitHub仓库大小,优化git仓库,彻底清除垃圾文件)
1.初始化
git init #初始化仓库,新建一个Git仓库(新建了一个隐藏目录.git)
把远程仓库克隆到本地
git clone https://github.com/010test/phpcrontab.git #将在当前目录下创建phpcrontab目录
git clone https://github.com/010test/phpcrontab.git /home/yhm/test #将代码克隆到/home/yhm/test目录内
列出项目所有配置
git config --list
列出远程仓库别名
git remote
列出远程仓库别...阅读全文
Oct152019
laravel 自定义请求验证类
laravel的验证可以直接在控制器里面这样验证:
$validatedData = $this->validate([
'title' => 'required|unique:posts|max:255',
'body' => 'required',
]);
if ($validatedData ->fails()) {
//未通过处理
}
或
Validator::make($request->all(), [
'title' => 'required|unique:posts|max:255',
'body' => 'required',
])->validate()...阅读全文
Oct152019
MySQL批量更新数据(封装为php方法)
mysql更新语句很简单,更新一条数据的某个字段,一般这样写:
UPDATE mytable SET myfield = 'value' WHERE other_field = 'other_value';
如果更新同一字段为同一个值,mysql也很简单,修改下where即可:
UPDATE mytable SET myfield = 'value' WHERE other_field in ('other_values');
这里注意,other_values是一个逗号,分隔的字符串,如:1,2,3
1 常规方案
那如果更新多条数据为不...阅读全文
Oct142019
mysql 用户管理和权限设置
mysql 用户管理和权限设置的相关命令整理。
用户管理
mysql>use mysql;
查看当前数据库有哪些用户:
mysql>select host,user,password from user;
创建用户
mysql>create user zx_root;
修改用户名(修改user字段的值):
mysql>rename user feng to newuser; -- mysql 5之后可以使用,之前需要使用update 更新user表
删除某个用户
mysql>drop user newuser; -- mysql5...阅读全文