Getting JSON POST Data with PHP
When a JSON POST is sent with PHP, it is not possible to receive it with $_POST.
Let's write an example JSON POST operation.
fetch(`https://domain.com/api.php`, {
method: POST,
body: JSON.stringfy({
name: 'phpExample.NET'
})
})
Now you can receive and process this data in api.php as follows;
<?php
$data = json_decode(file_get_contents('php://input'), true);
print_r($data);
Comments
Popular Articles
Popular Tags
- #directive
- #Function
- #Json
- #Class
- #SASS
- #Form
- #Redirect
- #API
- #Special Characters
- #Special
- #Random
- #Generating
- #
- #Text
- #Ajax
- #URL
- #Encrypting
- #React
- #Show
- #timeAgo
- #PSR-4
- #Hide
- #DDOS Protection
- #DDOS
- #cURL
- #Logic For Displaying Posts
- #Error
- #Key
- #General Error
- #1364 Field
- #Abbreviation
- #Blade
- #Version
- #QR
- #QR Code Generating
- #Array
- #Arrays with Key Values to String Statement
- #Short Tag
- #Activate
- #Real Time
- #Socket.io
- #301
- #Custom Directives
- #Iframe Detection
- #Date
- #Characters
- #Insert
- #Autoloader
- #Composer
- #Reading
There are no comments, make the firs comment