linux日常命令

vi/vim 清空文件内容:     方法1:  键盘g  ->  输入  .,$d    方法2:     cat /dev/null > filename   方法3: echo "" > filename   方法4: > filename  方法5: ECS  然后输入dG 磁盘挂载: fdisk -l fdisk  /xxxx   #新增数据盘  n 新增分区   e 延伸分区  1 partion number  2028  first sector  enter last sector  w 写入 partprobe 同步数据盘   mkfs -t ext4 /xxx    设置系统所需格式 mkdir /mnt/adam  新建挂载路径  mount /xxx /mnt/adam  挂载 df -TH查看 

centos7.2 安装xdebug

下载 到官网下载源码  https://xdebug.org/download.php cd /wwwroot https://xdebug.org/files/xdebug-2.7.0alpha1.tgz 2.解压安装 mkdir xdebug   #创建目录 cp xdebug-2.7.0alphal.tgz –target-directory=./xdebug  #拷贝到创建目录 cd xdebug  #进入目录 tar -xvf xdebug-2.7.0alphal.tgz  #解压 cd xdebug-2.7.0alphal  /usr/local/php/bin/php -m  #查看是否已经看装模块  /usr/local/php/bin/phpize ./configure –with-php-config=/usr/local/php/bin/php-config make && make instal #编译安装 3.安装成功会提示 Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20170718/   +———————————————————————-+   |                                                                      |   |   INSTALLATION INSTRUCTIONS                                          |   |   =========================                                          |   |                                                                      |   |   See http://xdebug.org/install.php#configure-php for instructions   |   |   on how to enable Xdebug for PHP.                                   |   |                                                                      |   |   Documentation is available online as well:                         |   |   – A list of all settings:  http://xdebug.org/docs-settings.php     |   |   – A list of all functions: http://xdebug.org/docs-functions.php    |   |   – Profiling instructions:  http://xdebug.org/docs-profiling2.php   |   |   – Remote debugging:        http://xdebug.org/docs-debugger.php     |   |                                                                      |   |                                                                      |   |   NOTE: Please disregard the message                                 |   |       You should add "extension=xdebug.so" to php.ini                |   |   that is emitted by the PECL installer. This does not work for      |   |   Xdebug.                                                            |   |                                                                      |   +———————————————————————-+ 4.php.ini添加扩展    cd /usr/local/php/etc  vim php.ini   #最后一行写入    [xDebug] zend_extension = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20170718/xdebug.so" 5.  echo phpinfo();查看

PHP7.2+ each,count函数替代方法

each  这个函数在php7.2以后就弃用了  替代方法: function func_new_each(&$array){     $res = array();     $key = key($array);     if($key !== null){         next($array);         $res[1] = $res['value'] = $array[$key];         $res[0] = $res['key'] = $key;     }else{         $res = false;     }     return $res; } 实例: while (list ($key, $val) = $this->func_new_each($para)) {    if($key == "sign" || $key == "sign_type" || $val == "")continue;    else    $para_filter[$key] = $para[$key]; } 2. count  这个函数没有弃用,但是在7.2+上传递一个字符串参数的时候会报错:Warning:  count(): Parameter must be an array or an object that implements Countable 替代方法: function func_new_count($array_or_countable,$mode = COUNT_NORMAL){     if(is_array($array_or_countable) || is_object($array_or_countable)){         return count($array_or_countable, $mode);     }else{         return 0;     } }

Github oauth登陆错误:Request forbidden by administrative rules

查看了文档  https://developer.github.com/v3/#user-agent-required 出现 Request forbidden by administrative rules错误的原因请求没有user-agent头  在Request header加一个 user-agent就ok了 。 我的博客即将搬运同步至腾讯云+社区,邀请大家一同入驻:https://cloud.tencent.com/developer/support-plan?invite_code=1874o3fc4belz