PHP does not recognize Json code

1

I installed php + apache via Xampp. PHP is working, but does not recognize Json, does anyone know if I need to enable anything in php.ini?

Returns the error: Notice: Undefined index: jsoncallback

The return line is:

echo $_GET["jsoncallback"] . '(' . json_encode("Valor=" . $teste ) . ');';    

The code works, I've circled the same code on the localhost of another computer, and also on a remote server, and it works perfectly, only on this computer I installed via Xampp does not work.

Thank you

    
asked by anonymous 29.06.2014 / 15:41

1 answer

1

The error you're getting:

  

Notice: Undefined index: jsoncallback

Indicates that the index in array $_GET with name jsoncallback does not exist.

When you do:

echo $_GET["jsoncallback"];

You are trying to access an array entry that does not exist.

To better control this you should make use of the isset () function of PHP:

if (isset($_GET["jsoncallback"])) {
  echo $_GET["jsoncallback"];
}
else {
  echo "Não foi localizado: jsoncallback";
}

Note: You should check that the URL of the page has a URL with the name jsoncallback .

GET Reserved Variable - PHP

  

An associative array of variables passed to the current script via the URL parameters.

What translated:

  

An associative array of variables passed to the current script via URL parameters.

    
29.06.2014 / 16:22