<?php 
    static public function unlimitedForLevel($cate,$html='|—',$pid=0,$level=0){
        //建立空数组存储结果
        $arr = array();
        //循环$cate,如果这级的pid等于上一级的cid,就先压入数组,再找当前的下一级
        foreach ($cate as $v) {
            //查找当前分类是否有子分类
            if ($v['parent_id'] == $pid) {
                $v['level'] = $level + 1;
                $v['html'] = str_repeat($html, $level);

                $arr[] = $v;
                //递归合并数组
                $arr = array_merge($arr,self::unlimitedForLevel($cate,$html,$v['id'],$level+1));
            }
        }
        return $arr;
    }

    //静态方法获取多维数组递归结果
    static public function unlimitedForMore($cate,$name='child',$pid=0){
        $arr = array();
        foreach ($cate as $v) {
            if ($v['parent_id'] == $pid) {
                $v[$name] = self::unlimitedForMore($cate,$name,$v['id']);
                $arr[] = $v;
            }
        }
        return $arr;
    }

    //递归获取父函数
    static public function getParents($cate,$cid){
        $arr = array();
        foreach ($cate as $v) {
            if ($v['id'] == $cid) {
                $arr[] = $v;
                $arr = array_merge(self::getParents($cate,$v['parent_id']),$arr);
            }
        }
        return $arr;
    }

 ?>

使用tzselect修改时区

[root@localhost ~]# tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent or ocean.
 1) Africa
 2) Americas
 3) Antarctica
 4) Arctic Ocean
 5) Asia
 6) Atlantic Ocean
 7) Australia
 8) Europe
 9) Indian Ocean
10) Pacific Ocean
11) none - I want to specify the time zone using the Posix TZ format.
#? 5
Please select a country.
 1) Afghanistan           18) Israel                35) Palestine
 2) Armenia               19) Japan                 36) Philippines
 3) Azerbaijan            20) Jordan                37) Qatar
 4) Bahrain               21) Kazakhstan            38) Russia
 5) Bangladesh            22) Korea (North)         39) Saudi Arabia
 6) Bhutan                23) Korea (South)         40) Singapore
 7) Brunei                24) Kuwait                41) Sri Lanka
 8) Cambodia              25) Kyrgyzstan            42) Syria
 9) China                 26) Laos                  43) Taiwan
10) Cyprus                27) Lebanon               44) Tajikistan
11) East Timor            28) Macau                 45) Thailand
12) Georgia               29) Malaysia              46) Turkmenistan
13) Hong Kong             30) Mongolia              47) United Arab Emirates
14) India                 31) Myanmar (Burma)       48) Uzbekistan
15) Indonesia             32) Nepal                 49) Vietnam
16) Iran                  33) Oman                  50) Yemen
17) Iraq                  34) Pakistan
#? 9
Please select one of the following time zone regions.
1) east China - Beijing, Guangdong, Shanghai, etc.
2) Heilongjiang (except Mohe), Jilin
3) central China - Sichuan, Yunnan, Guangxi, Shaanxi, Guizhou, etc.
4) most of Tibet & Xinjiang
5) west Tibet & Xinjiang
#? 1

The following information has been given:

        China
        east China - Beijing, Guangdong, Shanghai, etc.

Therefore TZ='Asia/Shanghai' will be used.
Local time is now:      Tue Jul 19 22:05:59 CST 2016.
Universal Time is now:  Tue Jul 19 14:05:59 UTC 2016.
Is the above information OK?
1) Yes
2) No
#? yes
Please enter 1 for Yes, or 2 for No.
#? 1

You can make this change permanent for yourself by appending the line
        TZ='Asia/Shanghai'; export TZ
to the file '.profile' in your home directory; then log out and log in again.

Here is that TZ value again, this time on standard output so that you
can use the /usr/bin/tzselect command in shell scripts:
Asia/Shanghai

把 TZ='Asia/Shanghai'; export TZ 添加到 /etc/profile 文件中

source /etc/profile

问题描述

新版本的谷歌浏览器,会对 .dev 或者 .app 后缀的域名,在访问时强制跳转至https访问。
比如:你在谷歌浏览器中,访问 www.blog.dev 或者http://www.blog.dev 地址后,会强制跳转为 https://www.blog.dev
对于做 web 开发的人员来说,开发环境的服务器一般默认都是遵循 http 协议的,而不是 https 协议。这样,就导致我们无法用谷歌浏览器(新版QQ,360等浏览器都有这问题)进行测试。



- 阅读全部 -

Linux常见英文报错中文翻译(菜鸟必知)

1.command not found 命令没有找到

2.No such file or directory 没有这个文件或目录

3.Permission denied 权限不足

4.No space left on device 磁盘没有剩余空间

5.File exists 文件已经存在

6.Is a directory 这是1个目录

7.Not a directory 不是1个目录

8.Warning: Changing a readonly file 警告:改变一个只读文件

9.Found a swap file by the name ".1.swp" 发下了一个swap文件名字为1.swp

(vim编辑器碰到的意外关闭文件有缓存文件)

10.unrecognized option '--oldboy' 不识别的选项,去查看帮助

11.No route to host 没有路由到主机(防火墙没关)

12.connection refused 连接拒绝(防火墙没关或服务端口没开)

13.Access denied 访问拒绝(权限或者selinux)

转自:CSDN

redis是键值对的数据库,有5中主要数据类型:

字符串类型(string),散列类型(hash),列表类型(list),集合类型(set),有序集合类型(zset)

几个基本的命令:

KEYS * 获得当前数据库的所有键
EXISTS key [key ...] 判断键是否存在,返回个数,如果key有一样的也是叠加数
DEL key [key ...] 删除键,返回删除的个数
TYPE key 获取减值的数据类型(string,hash,list,set,zset)
FLUSHALL 清空所有数据库
CONFIG [get、set] redis配置
-inf 负无穷
+inf正无穷








- 阅读全部 -

1SQL运算符例子实际查询条件
eq=$map['id'] = array('eq',100);等效于:$map['id'] = 100;
neq!=$map['id'] = array('neq',100);id != 100
gt>$map['id'] = array('gt',100);id > 100
egt>=$map['id'] = array('egt',100);id >= 100
lt<$map['id'] = array('lt',100);id < 100
elt<=$map['id'] = array('elt',100);id <= 100
likelike$map['username'] = array('like','li%');username like 'li%'
betweenbetween and$map['id'] = array('between','1,8');id BETWEEN 1 AND 8
not betweennot between and$map['id'] = array('not between','1,8');id NOT BETWEEN 1 AND 8
inin$map['id'] = array('in','1,5,8');id in(1,5,8)
not innot in$map['id'] = array('not in','1,5,8');id not in(1,5,8)
and(默认)and$map['id'] = array(array('gt',1),array('lt',10));(id > 1) AND (id < 10)
oror$map['id'] = array(array('gt',3),array('lt',10), 'or');(id > 3) OR (id < 10)
xor(异或)xor两个输入中只有一个是true时,结果为true,否则为false,例子略。1 xor 1 = 0
exp综合表达式$map['id'] = array('exp','in(1,3,8)');$map['id'] = array('in','1,3,8');

注意:exp 不是一个运算符,而是一个综合表达式以支持更复杂的条件设置。exp 的操作条件不会被当成字符串,可以使用任何 SQL 支持的语法,包括使用函数和字段名称。

php自带函数file_exists判断文件是否存在,is_dir判断文件夹是否存在

如:

//当/www/index.php 都实际存在时
$file='index.php';
$dir='/www/';
if(file_exists($dir.$file)){
    echo '文件'.$file.'存在';
}else{
    echo '文件'.$file.'不存在';
}
if(is_dir($dir)){
    echo '目录'.$dir.'存在';
}else{
    echo '目录'.$dir.'不存在';
}