您可以使用
parsekit通过pecl可以从
pecl website下载或安装:
sudo pecl install parsekit
在运行时从PHP代码字符串获取OPcodes:
此命令的语法是:
array parsekit_compile_string ( string $phpcode [, array &$errors [, int $options = PARSEKIT_QUIET ]] )
参数:
phpcode
A string containing phpcode. Similar to the argument to eval().
errors
A 2D hash of errors (including fatal errors) encountered during compilation. Returned by reference.
options
One of either PARSEKIT_QUIET or PARSEKIT_SIMPLE. To produce varying degrees of verbosity in the returned output.
Return Values
Returns a complex multi-layer array structure as detailed below.
这样的一个示例用法是:
$ops = parsekit_compile_string('
echo "Foo\n";
', $errors, PARSEKIT_QUIET);
var_dump($ops);
?>
输出太长,无法包含在此答案中,但在documentation page上可用
在运行时从PHP文件获取OPcodes:
非常类似于上述方法,但解析文件而不是字符串。