In order to be compatible with emoji expressions and other special symbols, the system uses the urlencode() function to process the data when the data is passed in, saves the processed data to the content field, and saves the original string to content_bak field, when using it, urldecode() the content field first, and then json_encode() the entire set of data and return it to the front desk.
The interface never returns any data, but the http status code is 200
1. The nginx return length limit is exceeded?
No, because the array can be output when using var_dump() directly, and this output is also returned by nginx.
2. Return false after discovering the json_encode() array
For debugging, use the json_last_error() function to get the error code 5, which corresponds to JSON_ERROR_UTF8, indicating that there are non-utf8 characters in the data. Are some abnormal characters passed in? But even abnormal characters will be urlencode() and then stored, so there should not be an error in the data content.
3. It is found that there is a special character ? in the array before json_encode(). After comparing the content_bak data, the reason has been basically determined.
Because the two fields content and content_bak are stored using TEXT (MySql), since the data this time is very long, after urlencode(), the length has already exceeded the maximum length of TEXT, 65535, so only urlencode is stored. () After the 65535th position of the string, half a character is intercepted, so an error of JSON_ERROR_UTF8 occurs during json_encode().
Just change the field type from TEXT to the following table