3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Token { function __construct($type = null, $content, $line = null){ $this->type = $type; $this->content = $content; $this->line = $line; } } $tokens = token_get_all('<?php // lol bar baz bar /* ( ) stuff */ bar '); foreach($tokens as $offset => $token){ $tokens[$offset] = is_array($token) ? new Token($token[0], $token[1], $token[2]) : new Token(null, $token, null); } print_r($tokens);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 31
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 31
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 22
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/DgNh1
function name:  (null)
number of ops:  36
compiled vars:  !0 = $tokens, !1 = $token, !2 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'token_get_all'
          1        SEND_VAL                                                 '%3C%3Fphp+%0A%2F%2F+lol+bar+baz%0Abar+%2F%2A+%0A%28%0A%0A%29%0Astuff+%0A%0A%0A%2A%2F%0Abar+'
          2        DO_ICALL                                         $3      
          3        ASSIGN                                                   !0, $3
   24     4      > FE_RESET_R                                       $5      !0, ->31
          5    > > FE_FETCH_R                                       ~6      $5, !1, ->31
          6    >   ASSIGN                                                   !2, ~6
   25     7        TYPE_CHECK                                  128          !1
          8      > JMPZ                                                     ~9, ->22
          9    >   NEW                                              $10     'Token'
         10        CHECK_FUNC_ARG                                           
         11        FETCH_DIM_FUNC_ARG                               $11     !1, 0
         12        SEND_FUNC_ARG                                            $11
         13        CHECK_FUNC_ARG                                           
         14        FETCH_DIM_FUNC_ARG                               $12     !1, 1
         15        SEND_FUNC_ARG                                            $12
         16        CHECK_FUNC_ARG                                           
         17        FETCH_DIM_FUNC_ARG                               $13     !1, 2
         18        SEND_FUNC_ARG                                            $13
         19        DO_FCALL                                      0          
         20        QM_ASSIGN                                        ~15     $10
         21      > JMP                                                      ->28
         22    >   NEW                                              $16     'Token'
         23        SEND_VAL_EX                                              null
         24        SEND_VAR_EX                                              !1
         25        SEND_VAL_EX                                              null
         26        DO_FCALL                                      0          
         27        QM_ASSIGN                                        ~15     $16
         28    >   ASSIGN_DIM                                               !0, !2
         29        OP_DATA                                                  ~15
   24    30      > JMP                                                      ->5
         31    >   FE_FREE                                                  $5
   28    32        INIT_FCALL                                               'print_r'
         33        SEND_VAR                                                 !0
         34        DO_ICALL                                                 
         35      > RETURN                                                   1

Class Token:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DgNh1
function name:  __construct
number of ops:  10
compiled vars:  !0 = $type, !1 = $content, !2 = $line
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV_INIT                                        !0      null
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      null
    6     3        ASSIGN_OBJ                                               'type'
          4        OP_DATA                                                  !0
    7     5        ASSIGN_OBJ                                               'content'
          6        OP_DATA                                                  !1
    8     7        ASSIGN_OBJ                                               'line'
          8        OP_DATA                                                  !2
    9     9      > RETURN                                                   null

End of function __construct

End of class Token.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.25 ms | 1400 KiB | 17 Q