We usually know the syntax when running PHP. For example, deploy the PHP source file under Apache and access the file through a browser.
Sever 500
The error occurs when the server executes our script. At this time, we may guess that PHP has a syntax error, but it is only possible. However, if we can detect syntax errors before deploying a web server (such as APACHE), it will save a lot of debugging time.
First, let's explain why the above is only possible because there are many reasons for 500 errors, such as database connection errors, such as file reading errors. Therefore, syntax errors are not unique, in this way, debugging is required. If you use a framework like yii for development and enable its debug flag, it will become relatively simple and the corresponding error will be displayed directly in the browser.
But even so, there is still no simple and effective method. What we use is Php executableProgram, Using its syntax detection function:
Php-l
Note that the lower case of L is not I in HI.
L is the function of detecting syntax provided by PHP.
If you are using vim and Linux
: PhP %
If Vim is used in windows
:! PHP %
% Indicates the current file.
If all PHP files under the current file are detected,
For
I
In
*. Php;
Do
Php-L $ I;
Done
All files including subdirectories are:
Find
.-Name \ *. php-
Exec
Php-l
"{}"
\;
End.