PHP

PHP学习记录

一次网站访问缓慢的排查过程

1
PHP 7.1.x (cli) (built: Sep 21 2018 22:43:43) ( NTS ) 有用户反馈说,网站访问非常缓慢 第一感觉 是不是redis 挂了?(因为之前有一次是这个原因) 经过排除redis运行正常 那数据库是不是访问缓慢呢? 经过测试 同服务器的golang程序 速度非常快,并且查看sql执行的日志 也没有发现有慢的语句,排...
赞 (0)阅读(69)

golang和php闭包对比

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 package main   import "fmt"   func adder() func(int) int { sum := 0 return func(i in...
赞 (0)阅读(76)

imagettftext因为enable-gd-jis-conv导致乱码的解决方法

imagettftext ===>> 点击查看函数说明 1.重新编译去掉  enable-gd-jis-conv 选项   2.imagettftext()也接受另外一种字符表示方法,类似HTML的字符参考。说“类似”是因为GD只接受数字参考,所以内部函数 (如 mb_convert_encoding) 转出来的没用。 以下的函数可以将...
赞 (0)阅读(103)

centos7+php71 安装流程

2
接上一篇:https://blog.phpstu.com/server/nginx-server/716 7.1新特性http://php.net/manual/zh/migration71.new-features.php 挺牛的,我觉得新项目最好还是用新版的PHP,性能会有不少提升。旧项目就要慎重考虑了毕竟重构也是很耗时的 下面开始安装: 版本信息 ph...
赞 (0)阅读(59)

php文件下载控制速度坑

下载文件代码 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 public function down($filename) { if(file_exists($filename) &&...
赞 (0)阅读(66)

for 和foreach 到底谁快?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 <?php   $count=100000; $arr=range(1,$count,1); $ts = microtime(true); for ($i = 0; $i <$c...
赞 (0)阅读(68)

Yii2框架的Assets资源包的使用

assets目录 类继承自: yii\web\AssetBundle 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 //资源文件,并且可以web访问的目录 //public $sourcePath 资源路径 当资源不再web可以访问的路径...
赞 (0)阅读(75)

yii2 load 时不加载非验证字段

第一步:数据发送到后台后,通过 $data = YII::$app->request->post() (假如是post请求) $model = new User(); 调用$model->load()把接受的数据 $data 载入对象中 第二步: 看load方法 (vendor\yiisoft\yii2\base\Model.php) 1 2 3 4 5 6...
赞 (0)阅读(60)

php中 static 和 self的区别

self 不会指向实例化的类,而指向本身所在的类, 调用顺序->在本身类中找->找不到报异常 static 指向实例化的类,调用顺序是 从实例化类中找–>然后找父类–>找不到报异常 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25...
赞 (0)阅读(55)

7.x 中Throwable 异常和错的接口

Throwable Throwable is the base interface for any object that can be thrown via a throw statement in PHP 7, including Error and Exception. Exception 实现了 Throwable接口 因此如果 应用 只在7.x中运...
赞 (0)阅读(74)