代码编辑工具notepad++;
环境phpstudy;oh-storm; notepad++;
部署工具:Capistrano
参考工具http://www.w3school.com.cn/php/
//查看日志
1:ssh连接服务器;2:进入到日志目录/application/runtime/logs/... 3:ls -l 查看文件列表 4:tail -f a.log 查看 (写入日志echo **** >> a.log)
ssh连接服务器前需服务器支持ssh 配置windows ssh:http://blog.chinaunix.net/uid-25603759-id-252295.html cygwin账号:iZ25mensz\cyg_server ; cygwinname cyg_server
数据库连接
if(mysql_connect("localhost","root","my password")){
mysql_select_db("databasename");
mysql_query("set names 'utf8'");
$sql = "insert into firstinfotable(index key,value) values ('$paral', '$para2')";
if(false == mysql_query($sql)){
echo "false";
return;
}
mysql_close();
echo "success!";
}
框架访问数据库
$result = D(‘tablename');
$par = I('val');
$list = $result->where("name='%s'",array($par))->select();
获取url参数
http://www.baidu.com/test.php?par1=geng&par2=yanli&fun=test
$fun = $_GET["fun"];
$para1 = $_GET["par1"];
$para2 = $_GET["par2"];
$fun($para1,$para2);
echo son_encode(array("first"=>$par1,"sec"=>$par2));
url说明
ip//thinkphp_3.2/index.php/Home/controllername/methord 或 在index.php的apppath后增加define("BIND_MODULE",'Home'); 就可以替代不写Home/
打印客户端请求参数
va r_dump($_REQUEST);
获取post数据
$in = $_POST['JsonString'];
$J = json_decode($in);
setValue($J->valA, $J->valB);
sql语句
插入("insert into soil (infos, append) VALUES ('{$index},'{$value}')"); ---双引号里的内容需要用{}包含住才能解析。
php安装目录(mac)
/Library/WebServer/Document/thinkphp/
/Application/Home/Controller/UserController.class.php内funoutput方法访问 localhost/index.php/Home/User/funoutput?name=ge
重启
sudo apachectl restart
//multipart传文件 (需要给保存的文件增加读写权限)
服务器端if($_FILES['piczip']['error'] === 0){
$res = array();
$config = array(
'rootPath' => 'C:\\WWW\\',//app\\Brand\\',
'savePath' => '10000\\',
'exts' =>'zip,png,jpg,jpeg,gif',
'maxSize'=>0,
);
$upload = new \Think\Upload($config);
$result = $upload->uploadOne($_FILES['piczip']);
if(!$result){
$res['code'] = 1;
$res['Message'] = $upload->getError();
}else{
$filedir = $config['rootPath'];
if(file_exists($filedir.$rel['savePath'].$rel['savename'])){
@exec('unzip -d '.$filedir.$rel['savepath'].substr($rel['savename'],0,-4).'/'.' '.$filedir.$rel['savePath'].$rel['savename']);
$final_file = $filedir.$rel['savePath'].substr($rel['savename'],0,-4);
}
$res['code'] = 0;
$res['Message'] = 'OK';
}
echo json_encode($res);
}
客户端:
[request setFile:imagepathforKey:@"piczip"];
$img_name = md5(uniqid(rand())) . ".jpg";
$path = "C:\\WWW\\app\\Brand\\" .$num."\\";
mkdir($path,0777, true);
$file = fopen($path . $img_name, "w");
fwrite($file, base64_decode($dejson['us_pic']));
fclose($file);