阿里云服务器自建 MySQL 无法远程连接,一般存在于三个问题:
1. 安全组配置需开放 3306 端口,默认不开放
LIUGUOFENG THE DARKEST HOUR IS THAT BEFORE THE DAWN
使用 SourceTree 向 码云 gitee.com (git.oschina.com) 推送代码时报错,报错信息如下
error: rpc failed; HTTP 413 curl 22 The requested URL returned error: 413 Request Entity Too Large
配置文件如下:
解决方法: 由 HTTP 提交修改为 SSH 提交 Continue reading OSChina Push error: rpc failed 失败 解决方法
做个记录
symfony/dom-crawler 使用入门
> composer require "symfony/dom-crawler"
<?php use Symfony\Component\DomCrawler\Crawler; require 'vendor/autoload.php'; $html = <<<'HTML' <!DOCTYPE html> <html> <body> <p class="message">Hello World!</p> <p>Hello Crawler!</p> </body> </html> HTML; $crawler = new Crawler($html); foreach ($crawler as $domElement) { var_dump($domElement->nodeName); }
http://symfony.com/doc/current/components/dom_crawler.html
https://segmentfault.com/q/1010000009019518
PHP 使用 CURL 进行输出时乱码,因为有些网页编码为 GBK 或 GB2312,需要把GBK,GB2312等网页常用格式转成UTF-8。
if(! mb_check_encoding($str, 'utf-8')) { $str = mb_convert_encoding($str,'UTF-8','gbk'); }
> crontab -e
0 3 * * * /sbin/reboot
设置凌晨 3 点重启服务器,但未生效
原因是 crontab 程序需重启
> /etc/init.d/crond restart
CentOS 7 使用
service crond restart
systemctl restart crond
以下为测试:
基于 Javascript 驱动的命令行webkit引擎,轻量级,安装简单,开发快速,渲染速度较快,无界面的 webkit 浏览器。 phontomjs 跟一般浏览器一样可以加载网页,但不同的是它不会把网页显示出来,在加载网页后它会提供一系列的 Javascript API 给程式人员使用,包括 DOM 元件的控制﹑CSS 的选择器﹑JSON﹑HTML5 的 Canvas 和 SVG 。
Continue reading PhantomJS 在 Windows 下实现网站自动截图
我们在使用 git push 或 clone 或其他命令的时候,有时候会遇到这类问题,如图:
fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
出现这个问题是因为没有在 github 账号添加 SSH key Continue reading Git “Could not read from remote repository.Please make sure you have the correct access rights.”解决方案
使用的 LNMP 一键安装包
Nginx 虚拟主机配置文件所在目录:/usr/local/nginx/conf/vhost/
Nginx 主配置文件在:/usr/local/nginx/conf/nginx.conf
打开相应 conf 配置文件,添加
Continue reading Nginx 使用一些配置<?php function str_rev($str){ for($i = 0;true;$i++){ if(!isset($str[$i])){ break; } } $return = ""; for($j=$i-1;$j>=0;$j--){ $return .= $str[$j]; } return $return; } echo str_rev('abcdefg');
输出:
gfedcba
重点:字符串可以当数组来使用。
字符串中的字符可以通过一个以0为开始的,用类似数组结构中的方括号包含对应的数字来查找和修改,比如 $str[42], 可以把 字符串想像数组 。
跳出循环,使用 isset() 来判断。
<?php function array_mer(){ $return = []; $array = func_get_args(); foreach($array as $arr){ if(is_array($arr)){ foreach($arr as $val){ $return[] = $val; } } } return $return; } var_dump(array_mer([1],[1,2],[3,5]));
输出:
array(5) { [0]=> int(1) [1]=> int(1) [2]=> int(2) [3]=> int(3) [4]=> int(5) }
重点:func_get_args() 动态获取参数的函数