How to access route, post, get etc. parameters in Zend Framework 2

前端 未结 5 1750
野性不改
野性不改 2020-11-27 10:06

How can I get various parameters related to the page request in zf2? Like post/get parameters, the route being accessed, headers sent and files uploaded.

5条回答
  •  执笔经年
    2020-11-27 10:41

    All the above methods will work fine if your content-type is "application/-www-form-urlencoded". But if your content-type is "application/json" then you will have to do the following:

    $params = json_decode(file_get_contents('php://input'), true); print_r($params);

    Reason : See #7 in https://www.toptal.com/php/10-most-common-mistakes-php-programmers-make

提交回复
热议问题