On the bizarre problem of json_encode in PHP

for example: there is an array queried from the database, normally using echo josn_encode (the output json string after $a); should be

[{"id":"1","name":"aaa","age":"23"},{"id":"2","name":"aaa","age":"23"}]

as above, the output with integer fields in the database will also be enclosed in double quotation marks, but it will be output like this when it is changed to another server recently.

[{"id":1,"name":"aaa","age":23},{"id":1,"name":"aaa","age":23}]

the value of an integer, such as 1BI 23 without double quotation marks, is very strange. I don"t know what"s going on. Do you have a great god?

Oct.31,2021

before josn_encode ($a); ) var_dump ($a);


may be a database problem on another server. The landlord can check whether it is a database problem or a php problem

https://blog.csdn.net/woshiha.


first make sure that the output in the database is in quotation marks?
my feeling is that id is generally an integer, and the output of the database will also be an integer, so there is also an integer
after json, so I think the problem is not the cause of json. The underlying zval of php defines a type for you when defining it, and json will not be idle to change the type for you. That's a lot of trouble, so let's see if the output of the database is an integer

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3280b-4d4ba.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3280b-4d4ba.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?