Under Windows 10 64 and Yii 2, the RESTful interface responds to the JSON format, and the CakePHP is used as the HTTP client, and the response data is forwarded to the browser again, and the browser side cannot resolve the solution.
1. Preliminary suspicion is a problem caused by the BOM header, save as the code in EditPlus: UTF-8 + BOM, as shown in Figure 1
2. Execute git commit, the difference: the text is the same, but the file does not match. The following differences are found: encoding method (ASCII, UTF-8 BOM), as shown in Figure 2
3. Select the project in phpstorm, right-click to execute remove BOM, as shown in Figure 3
4. Execute git submission, find that the BOM header of the file has been removed, there is no difference, the execution effect of the remove BOM is in line with expectations, and confirm that there is no BOM header in the program file, as shown in Figure 4
5. Copy the data of the response in the browser to the TXT document, and then check it in Windwos Posershell, and find that there is a BOM header, as shown in Figure 5
6. The final analysis found that the reason is that in the configuration file of the PHP HTTP Client (based on CakePHP), a file has a BOM header, remove the BOM header, and the browser can resolve it normally.




