Answer the question
In order to leave comments, you need to log in
How to catch and read http request?
Hello, I have a scanner that sends me an http request with the content of application/json. It contains the following data:
{"Name": , "Login": <string>, "Password": <string>, "Year of birth": }
How can I catch this query and read the data (raise each to their separate variable) ?
Thanks in advance! I use php 7.4.9
Answer the question
In order to leave comments, you need to log in
//Считываем данны из тела HTTP запора
$json = file_get_contents('php://input');
//Превращаем JSON строчку в PHP массив
$data = json_decode($json);
//Содержимое переменной $data
// [
// "Имя" => <строка>,
// "Пароль" => <строка>,
// "Год рождения" => <строка>,
// ]
Greetings.
Every site on the world wide web does the same.
Everyone.
This is one of the most common tasks in web development.
There are millions of examples online on how to do this.
Try once in a lifetime to use the search.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question