手机浏览 RSS 2.0 订阅 膘叔的简单人生 , 腾讯云RDS购买 | 超便宜的Vultr , 注册 | 登陆
浏览模式: 标准 | 列表分类:PHP

simplepie解析爱范儿的RSS出错

 用Simplepie解析爱范的源时,出现如下错误:http://www.ifanr.com/feed is invalid XML, likely due to invalid characters. XML error: Invalid character at line 604, column 37,比较麻烦。

 
最后在Simplepie的代码的1397行里加入:
XML/HTML代码
  1. $this->raw_data = preg_replace('/[^\P{C}\n]+/u','',$this->raw_data);  
说实在的,这种不可见的字符最TMD恶心了!~
 
 

Yii2 PJAX的URL,微信签名错误

因为用了pjax,所以URL在请求的时候都是被自动加了?pjax-container=xxxxx,但请求完pjax后,location的pushState又会去掉这个pjax-container。所以要解决签名问题,其实就是在签名的时候把pjax-container去掉

因此jssdk()->config(xxx)的时候,先在前面加入jssdk()->setUrl(Url::to([''],true))->config('')...问题解决!

就是这么简单!

 

redis 127.0.0.1和localhost的性能区别

 不多说上图

 
[2017-10-13 08:52:28]{"router":"site/test","process_time":1.05578303337,"include_files":110}
[2017-10-13 08:52:29]{"router":"site/test","process_time":1.65018391609,"include_files":110}
[2017-10-13 08:52:30]{"router":"site/test","process_time":2.24326276779,"include_files":110}
[2017-10-13 08:52:31]{"router":"site/test","process_time":2.83484601974,"include_files":110}
[2017-10-13 08:52:32]{"router":"site/test","process_time":3.45267605782,"include_files":110}
 
 
[2017-10-13 08:52:43]{"router":"site/test","process_time":0.045606136322,"include_files":110}
[2017-10-13 08:52:43]{"router":"site/test","process_time":0.0466020107269,"include_files":110}
[2017-10-13 08:52:44]{"router":"site/test","process_time":0.0419600009918,"include_files":110}
[2017-10-13 08:52:44]{"router":"site/test","process_time":0.0458340644836,"include_files":110}
[2017-10-13 08:52:44]{"router":"site/test","process_time":0.0436880588531,"include_files":110}
 
因为在框架里面,所以include_files就这么多(没办法,没开始opcache)
前5条是用的localhost后5条是127.0.0.1,瞅瞅,就是这样的区别!
 

composer 加速插件

先说再写:

全局更新
  1. composer global require hirak/prestissimo  

即使你用了这玩意,还是得先用国内的源,否则所谓的加速也是白搭。
GITHUB在这里:https://github.com/hirak/prestissimo
看官网的介绍,提升有10倍,虽然 我们在国内没有这么高的提速,但感觉上还是快了不少(应该不是安慰剂)
 

mysql 函数与 pdo函数的对比及使用

mysql在升到php7后,原有的mysql_*函数都没有了,如果要迁移,可以参考 这一篇:https://stackoverflow.com/questions/36073703/mysql-to-pdo-comparison-table

介绍的比较详细,比如mysql常用的几个函数的转换写法,这里都有了:
随便截一点内容,详细的还是去网站看:
 

MySQL_ Original Driver to PDO Comparative Table

Introduction:

This table is not intended to be a tutorial or a guide to PDO, but to provide a correspondence between MySQL_ and PDO. So, some important PDO commands are missing, if they don't have a MySQL_ correspondence.

Among these omitted commands, there is a major PDO feature, the prepared statements. I strongly recommend to use it, also if only cited in this guide.

This is a very extended answer. I'm sorry for the low quality of spelling (I'm not english) and for the typos. I will try to correct and improve it in the next few days. Any suggestion or contribution is welcome.

Naming Conventions:

To avoid misunderstanding, in this answer I use:

In PDO, we have two major object types, the PDOObject (the connection between PHP and a database server) and the PDOStatement (a prepared statement and, after the statement is executed, an associated result set). In this answer, variable names are:

  • $dbh, refer to PDOobject;
  • $stmt, refer to PDOStatement.