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(); 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/BVMsV
function name:  (null)
number of ops:  38
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          
   20    16        ASSIGN                                                       !2, <array>
   21    17        INIT_FCALL                                                   'get_line'
         18        SEND_VAR                                                     !0
         19        DO_FCALL                                          0  $16     
         20        ASSIGN_DIM                                                   !2
         21        OP_DATA                                                      $16
   22    22        INIT_FCALL                                                   'get_line'
         23        SEND_VAR                                                     !0
         24        DO_FCALL                                          0  $18     
         25        ASSIGN_DIM                                                   !2
         26        OP_DATA                                                      $18
   23    27        INIT_FCALL                                                   'get_line'
         28        SEND_VAR                                                     !0
         29        DO_FCALL                                          0  $20     
         30        ASSIGN_DIM                                                   !2
         31        OP_DATA                                                      $20
   25    32        INIT_FCALL                                                   'json_encode'
         33        SEND_VAR                                                     !2
         34        SEND_VAL                                                     128
         35        DO_ICALL                                             $21     
         36        ECHO                                                         $21
         37      > RETURN                                                       1

Function get_line:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BVMsV
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
-----------------------------------------------------------------------------------------
   11     0  E >   RECV                                                 !0      
   12     1        INIT_METHOD_CALL                                             !0, 'next'
          2        DO_FCALL                                          0  $3      
          3        ASSIGN                                                       !1, $3
   14     4        ASSIGN                                                       !2, <array>
   15     5        INIT_METHOD_CALL                                             !0, 'key'
          6        DO_FCALL                                          0  $7      
          7        ASSIGN_DIM                                                   !2, 'line'
          8        OP_DATA                                                      $7
   16     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
   17    14      > RETURN                                                       !2
   18    15*     > RETURN                                                       null

End of function get_line

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
146.74 ms | 1469 KiB | 12 Q