search

Home  >  Q&A  >  body text

php - Using yii2 to build restful api, yii\web\Response::$acceptParams is empty, can anyone help me?

If a request is sent via Accept: application/json; version=v1,
After content negotiation, yii\web\Response::$acceptParams will contain the value ['version' = > 'v1'].
But it is empty after printing. What is the reason?

1

2

<code>var_dump((new Response())->acceptParams);

</code>

黄舟黄舟2865 days ago381

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-05-16 13:13:16

    1

    2

    <code> var_dump(Yii::$app->response->acceptParams["sub-version"]);

    就可以了,被手册误导了</code>

    reply
    0
  • Cancelreply