日常零碎积累

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

http://dev.mysql.com/doc/refman/5.5/en/case.html

  • 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() and isset()

    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可以理解为输出左表所有匹配的行 和 右表与左表关联的行;
    其他几种可以类似这样理解。

转载于:https://www.cnblogs.com/liuwensheng/p/6065464.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值