本文共 429 字,大约阅读时间需要 1 分钟。
query("set names utf8"); //准备 $result = $pdo->prepare($sql); //执行,绑定字段 $result->execute(array('id'=>$id)); return $result->fetch(PDO::FETCH_ASSOC);}//php7新语法,null值合并$id = $_GET['id']?? 0;//有参数if($id){ //返回值 $user = show($id); if(empty($user)) { $user = array("errorno"=>"SN001","errormsg"=>'没有查找到数据!'); }}//参数错误else{ $user = array("errorno"=>"SN002","errormsg"=>"参数ID错误!");}print_r($user);
转载地址:http://npem.baihongyu.com/