你可以在有问题的文件上调用PHP -l.尽管如此,这将会出现问题.
它不会像die()那样处理运行时错误.
它不会像die()那样处理运行时错误.
test.PHP的:
<?PHP function check_code_file($filename) { $filename = escapeshellcmd($filename); system("PHP -l $filename 2>/dev/null 1>/dev/null",$status); if ($status) return false; return true; } if (check_code_file('test-good.PHP')) { include('test-good.PHP'); } if (check_code_file('test-bad.PHP')) { include('test-bad.PHP'); } print "finished\n";
测试good.PHP:
<?PHP print "here\n";
测试bad.PHP:
<?PHP die(
here finished