1 The namespace declaration must be written at the beginning of the script
If the following error occurs after running the PHP script:
Namespace declaration statement has to be the very first statement in the script
The reasons are as follows:
The namespace declaration statement must be at the front of the script.
<The statement of ?php must be in the first sentence of the script, even spaces or blank lines will not work.
However, if there are no blank lines or spaces in front of <?php, this error will still be reported. The reason is that I opened it with Notepad and modified the encoding. After opening it with Notepad, the BOM header was added to the file.
The solution is as follows:
Open it with EDITPLUS and save it as a file. The UF8 problem is solved. The original file becomes UF8- BOM
Why can’t I open many web pages for reading?
1 The namespace declaration must be written at the beginning of the script
If the following error occurs after running the PHP script:
Namespace declaration statement has to be the very first statement in the script
The reasons are as follows:
The namespace declaration statement must be at the front of the script.
<The statement of ?php must be in the first sentence of the script, even spaces or blank lines will not work.
However, if there are no blank lines or spaces in front of <?php, this error will still be reported. The reason is that I opened it with Notepad and modified the encoding. After opening it with Notepad, the BOM header was added to the file.
The solution is as follows:
Open it with EDITPLUS and save it as a file. The UF8 problem is solved. The original file becomes UF8- BOM
Turn on debug to see what the error is