PHP 8.6.0 Beta 2 available for testing

Yaf_Request_Abstract::getRaw

(Yaf >=3.2.2)

Yaf_Request_Abstract::getRawRetrieve the raw request body

説明

public function Yaf_Request_Abstract::getRaw(): ?string

Retrieves the raw request body.

パラメータ

この関数にはパラメータはありません。

戻り値

The raw request body as a string, or null on failure.

例1 Yaf_Request_Abstract::getRaw() example

<?php
class ApiController extends Yaf_Controller_Abstract
{
    public function createAction()
    {
        // Assuming the client POSTs '{"name":"yaf","version":3}'
        $raw  = $this->getRequest()->getRaw();
        $data = json_decode($raw, true);

        var_dump($data);
    }
}
?>

上の例の出力は、 たとえば以下のようになります。

array(2) {
  ["name"]=>
  string(3) "yaf"
  ["version"]=>
  int(3)
}

参考

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top