这可能也是一种选择: When (if ever) is eval NOT evil?
,似乎来得更快:
$nTestTiempo0 = microtime(true);
exec('php -l yourfile.php',$arrMsgError,$nCodeError);
$nTestTiempo1 = microtime(true);
echo "\n", '<p>Time in verify file with exec : '.($nTestTiempo1-$nTestTiempo0).' secs.</p>';
//Time in verify file with exec : 0.033198118209839 secs.
$nTestTiempo0 = microtime(true);
ob_start();
var_dump(eval('return true; if(0){?>'.file_get_contents('yourfile.php').'<?php };'));
$arrMsgError = explode("\n",trim(ob_get_contents()));
ob_end_clean();
$nTestTiempo1 = microtime(true);
echo "\n", '<p>Time in verify file with eval : '.($nTestTiempo1-$nTestTiempo0).' secs.</p>';
//Time in verify file with eval : 0.00030803680419922 secs.
$nTestTiempo0 = microtime(true);
@system('php -l yourfile.php',$nCodeError);
$nTestTiempo1 = microtime(true);
echo "\n", '<p>Time in verify file with system : '.($nTestTiempo1-$nTestTiempo0).' secs.</p>';
//Time in verify file with system : 0.032964944839478 secs.
包括文件和捕获异常:P – 2010-10-05 08:23:18
@Ignacio:万一未舌状(尽管我认为是这样):用错误处理程序将致命错误转换为异常不起作用,更不用说包含该文件将执行它,而这个模块不应该这样做。 – pinkgothic 2010-10-05 08:37:20
绝对是舌尖。正确的方法是告诉编译器编译它,然后捕获异常。 – 2010-10-05 08:39:38