search

Home  >  Q&A  >  body text

Why can't tp5 return an array?

//后台管理员验证方法
  public function check(Request $request){
    //初始返回的三个参数
    $status = 0;
    $result = '';
    $data = $request->param();
    
    //return ['status'=>$status,'message'=>$result,'data'=>$data];

    $returnVar=array('status'=>$status,'message'=>$result,'data'=>$data);
    //dump($returnVar); //能正确显示
    return $returnVar; //返回给前端为什么会提示返回数据类型错误呢?

  }

Why can’t I use return to return an array? Why does an error occur?


PhpNewerPhpNewer2386 days ago1453

reply all(2)I'll reply

  • a'ゞ时间

    a'ゞ时间2018-05-13 21:38:48

    tp5 control layer returns json by default

    reply
    1
  • PhpNewer

    PhpNewer2018-05-13 19:07:32

    Supplement: Can’t the tp5 array be returned with return?

    reply
    0
  • Cancelreply