微信的同步联系人功能

今天莫名其妙的发现微信的同步联系人功能,关键是哥没有开启过呀!!
他尼妹的自动开启着,这货是同步的什么呀!!!
不知道干啥的,但是还是赶紧关了。

Sublime Text 删除 Markdown Editing 插件后每次启动都报错

Sublime Text 之前装了 Markdown Editing 插件,今天删除之后,打开.md格式的文件,一直报下面这个错误。

error: Error loading colour scheme Packages/MarkdownEditing/MarkdownEditor.tmTheme: Error parsing plist xml: Failed to open file In file "Packages/MarkdownEditing/MarkdownEditor.tmTheme"

解决方法:
按ctrl + shift + p ,然后输入 set syntax:html 即可。

Nginx 设置 PHP_VALUE 的灵异问题

之前通过Apache里设置auto_prepend_file / auto_append_file 来实现记录页面执行时间,后来切换到Nginx后就没有设置这个了。

搜索一番,Nginx同样支持这种设置的。

配置如下:

fastcgi_param PHP_VALUE "auto_prepend_file=prepend.php";
fastcgi_param PHP_VALUE "auto_append_file=append.php";

配置好后,重新Nginx,查看phpinfo()的输出,发现有时候auto_prepend_file设置为空,如图。
[caption id="attachment_1204" align="alignnone" width="300"]nginx nginx[/caption]

搜索一番后,发现Nginx不支持多条PHP_VALUE的设置。

Quick little post on a problem I had while trying to use XHGui with my Nginx/PHP-FPM setup. I needed to be able to pass the auto_prepend_file and auto_append_file settings to PHP-FPM from Nginx. In apache you can declare multiple php_value settings. However, when I did the same in nginx, it would only reflect the second setting. Turns out you need to set all of your php_value’s in Nginx in a single string, and you separate them by new line characters.

如果有多条,需要将PHP_VALUE的设置合并到一条记录上,以" \n "进行分隔。

重新配置,如下:

fastcgi_param PHP_VALUE "auto_prepend_file=prepend.php \n auto_append_file=append.php";

重启Nginx,查看phpinfo(),配置生效了。

相关资料:
PHP-FPM, Nginx, PHP_VALUE, and Multiple Values

PHP函数的参数

代码如下:

function test($a, $b = time()) {
echo 'test';
}

执行结果如下:

Parse error: syntax error, unexpected '(', expecting ')' in C:\xampp\htdocs\index.php on line 3

你会发现,PHP报错了。
为什么呢?

看PHP官方对于函数参数的说明:

函数可以定义 C++ 风格的标量参数默认值。
PHP 还允许使用数组 array 和特殊类型 NULL 作为默认参数。
默认值必须是常量表达式,不能是诸如变量,类成员,或者函数调用等。

注意最后一句,默认值不能是变量,类成员或者函数调用。

CURLOPT_CONNECTTIMEOUT 和 CURLOPT_TIMEOUT的区别

There's a very distinctive difference between these two configurations within cURL. I'll try to definethemfor you, and then provide you a very common example which I shareto people who I teach about cURL.

CURLOPT_CONNECTTIMEOUT is designed to tell the script how long to wait to make a successful connection to the server before starting to buffer the output. Adestination's server which may be overloaded, offline or crashedwould probably make this setting becomeuseful.

CURLOPT_TIMEOUT isdesigned to tell the script how long to wait to receive acompletely buffered output from the server. A destination's hugefile, slow connection speeds or slow rendering would probably makethis setting become useful.

A good example of where these will both apply to, is when you'retelling cURL to download a MP3 file. CURLOPT_CONNECTTIMEOUT would be set at about 10 seconds which would mean that if no response is provided within 10 seconds then the script will abort, and CURLOPT_TIMEOUT would be set at about 100 seconds which would mean if the MP3 has not downloaded within 100 seconds then abort the script. It's the best way of explaining it to developers.

CURLOPT_CONNECTTIMEOUT:服务器没有相应的超时时间。

CURLOPT_TIMEOUT:服务器连接的超时时间。

最近性能优化中,发现接口请求有的会长达3s,检查框架代码后发现是由于没有设置超时时间导致。

相关资料:
What the different CURLOPT_CONNECTTIMEOUT and CURLOPT_TIMEOUT