HTML validator w3.org orada gibi bir PHP validator var mı?
You can validate the syntax without running a PHP script itself, seçeneği ile, php
komut satırından kullanarak "-l
":
$ php --help
Usage: php [options] [-f] <file> [--] [args...]
php [options] -r <code> [--] [args...]
php [options] [-B <begin_code>] -R <code> [-E <end_code>] [--] [args...]
php [options] [-B <begin_code>] -F <file> [-E <end_code>] [--] [args...]
php [options] -- [args...]
php [options] -a
...
-l Syntax check only (lint)
...
Örneğin, bir dosya ile bu içerir:
<?php
,
die;
?>
(Note the obvious error)
Alırsınız:
$ php -l temp.php
PHP Parse error: syntax error, unexpected ',' in temp.php on line 3
Parse error: syntax error, unexpected ',' in temp.php on line 3
Errors parsing temp.php
Integrating this in a build process, or as a pre-commit SVN hook, is nice, btw : it helps avoiding having syntax errors in production ^^
Ne diğerleri Bina söyledi:
error_reporting(E_ALL);
Basitçe PHP'nin kendi hata iletileri kullanarak yeterince iyi. Eğer gerçekten anal almak ve bir dizi kullanmak istiyorsanız Ancak, "standart" Örneğin bunu versiyon kontrol sistemi olarak önceden taahhüt kanca uygulayabilirsiniz ki, bir PHP Code Sniffer seçebilirler.
How useful is PHP CodeSniffer? Code Standards Enforcement in General?: İşte onların kullanışlılığı açıklayan bir SO soru