15/November:
Windows环境下安装php redis扩展
- 先查看php编译器版本:
phpinfo() 中的 Compiler选项
- 选择对应版本的扩展动态库: https://github.com/nicolasff/phpredis/downloads
- 将下载下来的扩展文件添加到 php下的ext文件夹
- 修改
php.ini
文件,添加下面代码后重启服务器
extension=php_igbinary.dll
extension=php_redis.dll
g++ -o hello.o helloworld.cpp
nohup ./helloworld.o &
17/November
CASE Syntax for MySQL
- Two kinds of syntax :
CASE case_value
WHEN when_value THEN statement_list
[WHEN when_value THEN statement_list] ...
[ELSE statement_list]
END CASE
Or:
CASE
WHEN search_condition THEN statement_list
[WHEN search_condition THEN statement_list] ...
[ELSE statement_list]
END CASE
eg:
SELECT
user_name,
credits,
CASE
WHEN credits < 10 THEN '差'
WHEN credits BETWEEN 10 AND 40 THEN '一般'
WHEN credits BETWEEN 40 AND 70 THEN '良好'
WHEN credits BETWEEN 70 AND 90 THEN '优秀'
WHEN credits BETWEEN 90 AND 100 THEN '极好'
ELSE '未知'
END as '信用评级'
FROM
members;
18/November
- what's the difference:
$null_value = null;
var_dump(isset($null_value));
var_dump($something);
var_dump(empty($null_value));
var_dump(empty($something));
//?
$strequal = 10;
if(isset($strnew = $strequal)){
echo $strnew;
}
Difference Between
empty()
andisset()
from stackoverflow:
http://stackoverflow.com/questions/20582962/whats-the-difference-between-isset-and-empty-in-php
ISSET checks the variable to see if it has been set.
In other words, it checks to see if the variable is any value except NULL or not assigned a value.
ISSET returns TRUE if the variable exists and has a value other than NULL.
That means variables assigned a "", 0, "0", or FALSE are set, and therefore are TRUE for ISSET.
EMPTY checks to see if a variable is empty.
Empty is interpreted as:
"" (an empty string),
0 (integer),
0.0 (float)`,
"0" (string),
NULL,
FALSE,
array() (an empty array),
and "$var;" (a variable declared, but without a value in a class.
20/November
相对路径之坑
```php
require_once("./Db.class.php");
require_once("./common.php");require_once(dirname(FILE) . "/Db.class.php");
require_once(dirname(FILE) . "/common.php");require_once(DIR."/Db.class.php");
require_once(DIR."/common.php");
```- nohup 指定输出文件
*/1 * * * * nohup php ./test.php > /tmp/test_runtime.log &
22/November
- 匿名函数 与 引用传值
$salary = [1,2,3,4,5];
$times = 100;
$ar_times = array_map(function($elm) use ($times){
$elm = $elm * $times;
return $elm;
}, $salary);
var_dump($ar_times);
array_map(function() use (&$salary){
$salary = ["EMPTY"];
}, $salary);
var_dump($salary);
- 关于mysql三种连接的理解方式:
LEFT JOIN可以理解为输出左表所有匹配的行 和 右表与左表关联的行;
其他几种可以类似这样理解。