3v4l.org

run code in 500+ PHP versions simultaneously
<?php $file = new SplTempFileObject(); for ($i = 0; $i < 100; $i++) { $file->fwrite("Foo $i\n"); } $file->rewind(); $file->key(); $file->current(); function get_line($file) { $triggerNext = $file->next(); $return = array(); $return['line'] = $file->key(); $return['contents'] = trim($file->current()); return $return; } $array = []; $array[] = get_line($file); $array[] = get_line($file); $array[] = get_line($file); echo json_encode($array, JSON_PRETTY_PRINT);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 5
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 5
Branch analysis from position: 14
Branch analysis from position: 5
filename:       /in/s1G2E
function name:  (null)
number of ops:  42
compiled vars:  !0 = $file, !1 = $i, !2 = $array
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   NEW                                                  $3      'SplTempFileObject'
          1        DO_FCALL                                          0          
          2        ASSIGN                                                       !0, $3
    5     3        ASSIGN                                                       !1, 0
          4      > JMP                                                          ->12
    6     5    >   INIT_METHOD_CALL                                             !0, 'fwrite'
          6        ROPE_INIT                                         3  ~8      'Foo+'
          7        ROPE_ADD                                          1  ~8      ~8, !1
          8        ROPE_END                                          2  ~7      ~8, '%0A'
          9        SEND_VAL_EX                                                  ~7
         10        DO_FCALL                                          0          
    5    11        PRE_INC                                                      !1
         12    >   IS_SMALLER                                                   !1, 100
         13      > JMPNZ                                                        ~12, ->5
    9    14    >   INIT_METHOD_CALL                                             !0, 'rewind'
         15        DO_FCALL                                          0          
   11    16        INIT_METHOD_CALL                                             !0, 'key'
         17        DO_FCALL                                          0          
   12    18        INIT_METHOD_CALL                                             !0, 'current'
         19        DO_FCALL                                          0          
   23    20        ASSIGN                                                       !2, <array>
   24    21        INIT_FCALL                                                   'get_line'
         22        SEND_VAR                                                     !0
         23        DO_FCALL                                          0  $18     
         24        ASSIGN_DIM                                                   !2
         25        OP_DATA                                                      $18
   25    26        INIT_FCALL                                                   'get_line'
         27        SEND_VAR                                                     !0
         28        DO_FCALL                                          0  $20     
         29        ASSIGN_DIM                                                   !2
         30        OP_DATA                                                      $20
   26    31        INIT_FCALL                                                   'get_line'
         32        SEND_VAR                                                     !0
         33        DO_FCALL                                          0  $22     
         34        ASSIGN_DIM                                                   !2
         35        OP_DATA                                                      $22
   28    36        INIT_FCALL                                                   'json_encode'
         37        SEND_VAR                                                     !2
         38        SEND_VAL                                                     128
         39        DO_ICALL                                             $23     
         40        ECHO                                                         $23
         41      > RETURN                                                       1

Function get_line:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/s1G2E
function name:  get_line
number of ops:  16
compiled vars:  !0 = $file, !1 = $triggerNext, !2 = $return
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   RECV                                                 !0      
   15     1        INIT_METHOD_CALL                                             !0, 'next'
          2        DO_FCALL                                          0  $3      
          3        ASSIGN                                                       !1, $3
   17     4        ASSIGN                                                       !2, <array>
   18     5        INIT_METHOD_CALL                                             !0, 'key'
          6        DO_FCALL                                          0  $7      
          7        ASSIGN_DIM                                                   !2, 'line'
          8        OP_DATA                                                      $7
   19     9        INIT_METHOD_CALL                                             !0, 'current'
         10        DO_FCALL                                          0  $9      
         11        FRAMELESS_ICALL_1                trim                ~10     $9
         12        ASSIGN_DIM                                                   !2, 'contents'
         13        OP_DATA                                                      ~10
   20    14      > RETURN                                                       !2
   21    15*     > RETURN                                                       null

End of function get_line

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.58 ms | 2810 KiB | 12 Q