Answer the question
In order to leave comments, you need to log in
Why does post_geson refuse to work?
Hello. Here I am doing a class for robots with data. Everything works except json_decode function
class data {
var $data;
function get($data) {
if (isset($_GET[$data])) {
$data = $_GET[$data];
$data = trim(htmlentities($data));
$this->data = $data;
}
}
function post($data) {
if (isset($_POST[$data])) {
$data = $_POST[$data];
$data = trim(htmlentities($data));
$this->data = $data;
}
}
function post_inc($data) {
if (isset($_POST[$data])) {
$data = $_POST[$data];
$data = preg_replace('/[^0-9]/','',$data);
$this->data = $data;
}
}
function post_gson($data) {
if (isset($_POST[$data])) {
$json = $_POST[$data];
$json = json_decode($json);
$this->data = $data;
}
}
function string($data) {
$data = trim(htmlentities($data));
$this->data = $data;
}
function result() {
return $this->data;
}
}
$data->post_gson('data');
$json = $data->result();
print_r($json);
Answer the question
In order to leave comments, you need to log in
and got it all figured out. There I got confused in the variables.
was written
function post_gson($data) {
if (isset($_POST[$data])) {
$json = $_POST[$data];
$json = json_decode($json);
$this->data = $data;
}
}
function post_gson($data) {
if (isset($_POST[$data])) {
$json = $_POST[$data];
$json = json_decode($json);
$this->data = $json;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question