Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions language/wrappers/php.xml
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,31 @@ file_put_contents("php://filter/write=string.rot13/resource=example.txt","Hello
<?php
file_put_contents('php://memory', 'PHP');
echo file_get_contents('php://memory'); // prints nothing
]]>
</programlisting>
</example>
<example>
<title>php://input to read JSON data from the request body</title>
<para>
This example demonstrates how to read JSON data from POST, PUT and PATCH
requests using <filename>php://input</filename>.
</para>
<programlisting role="php">
<![CDATA[
<?php
header('Content-Type: text/plain');

// Read raw input data from php://input
$jsonData = file_get_contents("php://input");

// Decode JSON data into a PHP array
$data = json_decode($jsonData, true);
if ($data !== null) {
echo "Received JSON data:\n";
print_r($data);
} else {
echo "Invalid JSON.";
}
]]>
</programlisting>
</example>
Expand Down
Loading