我有一个脚本,它使用php -l检查php文件中的语法错误。它在windows中运行良好,但在Linux中提供了不正确的输出:
正在检查是否存在语法错误的文件exec_ip.php的内容是(它有需要检查的语法错误):
<?php $arr['12] = 'asd'; ?>
剧本是:
$slash = file_get_contents('exec_ip.php'); //echo $slash; $tmpfname = tempnam("tmp", "PHPFile"); file_put_contents($tmpfname, $slash); exec("php -l ".$tmpfname,$error); $errtext = ''; foreach($error as $errline) $errtext.='<br>'.$errline; unlink($tmpfname); echo 'ERR:'.$errtext;
WINDOWS (WAMP) {CORRRECT}的结果:
ERR: Parse error: syntax error, unexpected T_STRING, expecting ']' in C:\WINDOWS\Temp\PHP1F1.tmp on line 2 Errors parsing C:\WINDOWS\Temp\PHP1F1.tmp
LINUX中的结果(Centos/cPanel) {未知输出}:
ERR: Content-type: text/html Content-type: text/html Content-type: text/html Content-type: text/html Content-type: text/html Content-type: text/html Content-type: text/html