Thinkphp5的基础用法

1.再html页面中使用config,就是tp3中的c方法,获取一个数组之后,
 
  

    
    
    

{:config('POLICE_MENU_NAME')[$Request.param.node]}

    2.if标签

    

<if condition="($Request.param.business_type == 1)">
3.在a标签中写url
 
  
<a href='{:url("index/checkNode",
            array(
                "business_id"=>$vo["business_id"],
                "node"=>$Request.param.node,
                "business_type"=>$Request.param.business_type,
                "status"=>"2"
            ))}'>不同意a>
4.获取前台页面传过来的参数
$unionid = $this->request->param('unionid');
5.ajax的返回
echo json_encode(array('id'=>123)); //直接输出echo

6.文件上传
public function uploadFile($file_account){
    $flag = 1;
    $data = '';
    if($file_account){
        $info = $file_account->move(ROOT_PATH . 'public' . DS . 'uploads');
        if($info){
            // 成功上传后 获取上传信息
            // 输出 jpg
            //echo $info->getExtension();
            // 输出 20160820/42a79759f284b767dfcb2a0197904287.jpg
            $data = $info->getSaveName();
            // 输出 42a79759f284b767dfcb2a0197904287.jpg
            //echo $info->getFilename();
        }else{
            // 上传失败获取错误信息
            $flag = 0;
            $data = $file_account->getError();
        }
    }
  return array('flag'=>$flag,'data'=>$data);
}

$res_up_account = $this->uploadFile($file_account);
$file_account = $request->file('account_pic');

 
  

你可能感兴趣的:(thinkphp)