PHP实行这段代码会经由如下4个步骤(确切的来说,该当是PHP的措辞引擎Zend)

1.Scanning(Lexing) ,将PHP代码转换为措辞片段(Tokens)

2.Parsing, 将Tokens转换成大略而故意义的表达式

php代码如何运行PHP代码履行步调 AJAX

3.Compilation, 将表达式编译成Opocdes

4.Execution, 顺次实行Opcodes,每次一条,从而实现PHP脚本的功能。

token_get_all()

将一段PHP代码 Scanning成Tokens;

var_dump(token_get_all('<?php echo \"大众Hello World\"大众; ?&gt;'));

Array(

[0] => Array(

[0] => 376

[1] => <?php

[2] => 1 )

[1] => Array(

[0] => 319

[1] => echo

[2] => 1 )

[2] => Array(

[0] => 379

[1] =>

[2] => 1 )

[3] => Array(

[0] => 318

[1] => \公众Hello World\公众

[2] => 1 )

[4] => ;

[5] => Array(

[0] => 379

[1] =>

[2] => 1 )

[6] => Array(

[0] => 378

[1] => ?>

[2] => 1 )

)