Check for PHP syntax errors

Source: Internet
Author: User

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:


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 IIn
*. Php;Do
Php-L $ I;

All files including subdirectories are:

Find .-Name \ *. php-Exec


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.