若有涉及到重复操作,尽量使用循环而非递归。 每一次递归调用都将过程在内存中复制一遍,如果有大数据的局部变量则会导致内存激增。 内存分配的图示:

原因:Ubuntu竟然在mysql的配置文件中默认绑定了本机。
解决方案:果断给注释掉。编辑配置文件/etc/mysql/my.cnf,注释掉里边的bind-address配置项。
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1
重启mysql
service mysql restart
因为开发环境是虚拟机Linux系统,开发时映射到Windows系统,所以在Windows系统下编辑的shell脚本,在执行时发现提示错误syntax error:unexpected end of file。
原因是DOS下文件和Linux下文件格式差异。DOS下的断行标志是\r\n,对应十六进制为0D 0A。而Unix下的断行标志是\n,十六进制为0A。
换句话说,在Windows系统下,换行用的两个符号:回车\r、换行\n,在Linux下只有一个\n。
DOS格式的文本文件在Linux下,有时候vi打开时行尾会显示^M,当然也有可能看不到,但是在vi界面会在下方显示该文件格式,如"test.txt" [dos] 9L, 113C,可以看出该文件是DOS格式。
在Linux下vi编辑执行如下命令即可:
vi test.txt
:set fileformat=unix
:wq
进入路由器管理界面,以TP-LINK为例,进入192.168.1.1管理界面,更改无线设置的基本设置项:
保存后,自动重启生效即可。
远端设置 Access-Control-Allow-Origin “*”
本地设置 withCredentials = true; 远端设置 Access-Control-Allow-Credentials true
Access-Control-Allow-Credentials 为 true 时,Access-Control-Allow-Origin不能同时为 *,不然会报跨错误,需要单独配置跨域准许。
** jQuery中Ajax写法: **
$.ajax({
url: a_cross_domain_url,
xhrFields: {
withCredentials: true
}
});
每次打开Git Bash时,默认的初始目录是/c/Windows/system,切换工作目录还需要手动敲cd /../..,太过麻烦。
右键点击Git Bash启动项,打开属性,找到快捷方式的起始位置一栏,改为自己的工作目录路径就可以了。
如图所示:

因为新工作需要使用Skype来交流,才发现Skype打开时默认占用80端口和443端口,导致Apache无法启动。
解决方法很简单,在Skype的设置里面,找到”工具->选项->高级->连接”,将端口80和端口443用于其他接入连接 前去掉勾选,就可以了。
如图所示:

http://www.tuicool.com/articles/ZRN3qu
MVC三个字母的含义:
M:Model 模型,负责数据库操作。
V:View 视图,负责调用Model调取数据,再调用模板,展示出最终效果。
C:Controller 控制器,程序的入口,决定改调用哪个View,并告诉View该做什么。
下面是一个超级简单的MVC结构实现:
Controller.php
include 'Model.php';
include 'View.php';
class Controller {
private $model = '';
private $view = '';
public function Controller(){
$this->model = new Model();
$this->view = new View();
}
public function doAction( $method = 'defaultMethod', $params = array() ){
if( empty($method) ){
$this->defaultMethod();
}else if( method_exists($this, $method) ){
call_user_func(array($this, $method), $params);
}else{
$this->nonexisting_method();
}
}
public function link_page($name = ''){
$links = $this->model->getLinks();
$this->view->display($links);
$result = $this->model->getResult($name);
$this->view->display($result);
}
public function defaultMethod(){
$this->br();
echo "This is the default method. ";
}
public function nonexisting_method(){
$this->br();
echo "This is the noexisting method. ";
}
public function br(){
echo "<br />";
}
}
$controller = new Controller();
$controller->doAction('link_page', 'b');
$controller->doAction();
Model.php
class Model {
private $database = array(
"a" => "hello world",
"b" => "ok well done",
"c" => "good bye",
);
//@TODO connect the database
//run the query and get the result
public function getResult($name){
if( empty($name) ){
return FALSE;
}
if( in_array($name, array_keys( $this->database ) ) ){
return $this->database[$name];
}
}
public function getLinks(){
$links = "<a href='#'>Link A</a> ";
$links.= "<a href='#'>Link B</a> ";
$links.= "<a href='#'>Link C</a> ";
return $links;
}
}
View.php
class View {
public function display($output){
// ob_start();
echo $output;
}
}
http://www.jb51.net/article/49498.htm