Php Code Checker

You can validate the syntax without running a PHPhường. script itself, using php from the command line, with the option "-l" :

$ php --help Usage: php <-f> <--> php -r <--> php <-B > -R <-E > <--> php <-B > -F <-E > <--> php -- php -a ... -l Syntax check only (lint) ...For example, with a tệp tin that contains :

(Note the obvious error)

You"ll get :

$ php -l temp.phpPHP.. Parse error: syntax error, unexpected "," in temp.php on line 3Parse error: syntax error, unexpected "," in temp.php on line 3Errors parsing temp.phpIntegrating this in a build process, or as a pre-commit Stoàn nước hook, is nice, btw : it helps avoiding having syntax errors in production ^^


Share
Improve this answer
Follow
edited Apr 7 "10 at 10:57
answered Sep trăng tròn "09 at 14:06
*

Pascal MARTINPascal MARTIN
372k7171 gold badges629629 silver badges648648 bronze badges
Add a comment |
9
You can run php with the -l or --syntax-check flag. It checks the syntax of the supplied tệp tin without actually running it

php --syntax-kiểm tra mytệp tin.php
Share
Improve this answer
Follow
answered Sep đôi mươi "09 at 14:05

*

Benjamin WohlwendBenjamin Wohlwkết thúc
28k1010 gold badges8383 silver badges9595 bronze badges
Add a bình luận |
2
PHP. engine itself.

Bạn đang xem: Php code checker

To turn on error messages:

error_reporting(E_ALL);
Share
Improve this answer
Follow
answered Sep 20 "09 at 14:04

*

adatapostadatapost
89.5k1818 gold badges139139 silver badges177177 bronze badges
Add a phản hồi |
2
Building on what others have sầu said:

error_reporting(E_ALL);Simply using PHP"s own error messages is good enough. However, if you really want lớn get anal và use a set "standard" you can opt for a PHPhường. Code Sniffer, which for example you can implement as pre-commit hooks khổng lồ your version control system.

Here"s a SO question which explains their usefulness: How useful is PHP CodeSniffer? Code Standards Enforcement in General?


Share
Improve this answer
Follow
edited May 23 "17 at 10:27
*

Community♦
111 silver badge
answered Sep đôi mươi "09 at 17:29
*

KushalPKushalP
10.1k66 gold badges3030 silver badges2727 bronze badges
Add a phản hồi |

Your Answer


Thanks for contributing an answer to Staông chồng Overflow!

Please be sure to lớn answer the question. Provide details & share your research!

But avoid

Asking for help, clarification, or responding lớn other answers.Making statements based on opinion; bachồng them up with references or personal experience.

Xem thêm: Là “Fan” Nhưng Bạn Có Biết 12 Cung Hoàng Đạo Fairy Tail, 12 Cung Hoàng Đạo Fairy Tail

To learn more, see our tips on writing great answers.


Draft saved
Draft discarded

Sign up or log in


Sign up using Google
Sign up using Facebook
Sign up using Thư điện tử and Password
Submit

Post as a guest


Name
Email Required, but never shown


Post as a guest


Name
E-Mail

Required, but never shown


Post Your Answer Discard

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy & cookie policy


The Overflow Blog
Featured on Meta
Linked
474
How can I perkhung static code analysis in PHP?
54
How useful is PHP. CodeSniffer? Code Standards Enforcement in General?
Related
2442
Validate decimal numbers in JavaScript - IsNumeric()
4763
How to validate an tin nhắn address in JavaScript
2773
How can I prevent SQL injection in PHP?
2068
When khổng lồ use self over $this?
3514
How to lớn validate an tin nhắn address using a regular expression?
2694
Deleting an element from an array in PHPhường
2510
How vày I get a YouTube Clip thumbnail from the YouTube API?
2176
How vì you parse và process HTML/XML in PHP?
4675
Reference — What does this symbol mean in PHP?
2564
Why shouldn't I use mysql_* functions in PHP?
Hot Network Questions more hot questions

Question feed
Subscribe to lớn RSS
Question feed To subscribe lớn this RSS feed, copy & paste this URL inkhổng lồ your RSS reader.


lang-php
Stack Overflow
Products
Company
Stack Exchange Network
site design / hình ảnh sản phẩm © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev2021.3.5.38726