0

If I include the statement:

    header("Content-Type: application/json; charset=utf-8"); 

in a PHP script, then execute the script in debug mode in VS2022 Community, I get an error

SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data 

only when using Firefox. I do not get the error with Edge, Chrome, or IE.

Taking the header statement out of the PHP and everything runs OK on all browsers. PHP.INI has default charset utf-8; Removing charset=utf-8 from the header has no effect.

I believe I'm dealing with a char-set issue, but don't know where the issue lies. The PHP file is on localhost and just does a database call to retrieve some rows from MySQL.

I can leave the header statement out, but I don't understand why the header fails. Can anyone explain?

Al G
  • 11
  • 2

0 Answers0