3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array_fill(0, 10000, 1); function by_reference(&$array) { echo "Inner by_reference: ", memory_get_usage(true), "\n"; foreach ($array as $var) { echo "Inner foreach: ", memory_get_usage(true), "\n"; break; } } function by_value($array) { echo "Inner by_value: ", memory_get_usage(true), "\n"; foreach ($array as $var) { echo "Inner foreach: ", memory_get_usage(true), "\n"; break; } } echo "Start: ", memory_get_usage(true), "\n"; by_reference($array); echo "After by_reference: ", memory_get_usage(true), "\n"; by_value($array); echo "After by_value: ", memory_get_usage(true), "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NkcOk
function name:  (null)
number of ops:  31
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'array_fill'
          1        SEND_VAL                                                 0
          2        SEND_VAL                                                 10000
          3        SEND_VAL                                                 1
          4        DO_ICALL                                         $1      
          5        ASSIGN                                                   !0, $1
   20     6        ECHO                                                     'Start%3A+'
          7        INIT_FCALL                                               'memory_get_usage'
          8        SEND_VAL                                                 <true>
          9        DO_ICALL                                         $3      
         10        ECHO                                                     $3
         11        ECHO                                                     '%0A'
   22    12        INIT_FCALL                                               'by_reference'
         13        SEND_REF                                                 !0
         14        DO_FCALL                                      0          
   24    15        ECHO                                                     'After+by_reference%3A+'
         16        INIT_FCALL                                               'memory_get_usage'
         17        SEND_VAL                                                 <true>
         18        DO_ICALL                                         $5      
         19        ECHO                                                     $5
         20        ECHO                                                     '%0A'
   26    21        INIT_FCALL                                               'by_value'
         22        SEND_VAR                                                 !0
         23        DO_FCALL                                      0          
   28    24        ECHO                                                     'After+by_value%3A+'
         25        INIT_FCALL                                               'memory_get_usage'
         26        SEND_VAL                                                 <true>
         27        DO_ICALL                                         $7      
         28        ECHO                                                     $7
         29        ECHO                                                     '%0A'
         30      > RETURN                                                   1

Function by_reference:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 17
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 17
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
Branch analysis from position: 17
filename:       /in/NkcOk
function name:  by_reference
number of ops:  19
compiled vars:  !0 = $array, !1 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        ECHO                                                     'Inner+by_reference%3A+'
          2        INIT_FCALL                                               'memory_get_usage'
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $2      
          5        ECHO                                                     $2
          6        ECHO                                                     '%0A'
    6     7      > FE_RESET_R                                       $3      !0, ->17
          8    > > FE_FETCH_R                                               $3, !1, ->17
    7     9    >   ECHO                                                     'Inner+foreach%3A+'
         10        INIT_FCALL                                               'memory_get_usage'
         11        SEND_VAL                                                 <true>
         12        DO_ICALL                                         $4      
         13        ECHO                                                     $4
         14        ECHO                                                     '%0A'
    8    15      > JMP                                                      ->17
    6    16*       JMP                                                      ->8
         17    >   FE_FREE                                                  $3
   10    18      > RETURN                                                   null

End of function by_reference

Function by_value:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 17
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 17
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
Branch analysis from position: 17
filename:       /in/NkcOk
function name:  by_value
number of ops:  19
compiled vars:  !0 = $array, !1 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1        ECHO                                                     'Inner+by_value%3A+'
          2        INIT_FCALL                                               'memory_get_usage'
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $2      
          5        ECHO                                                     $2
          6        ECHO                                                     '%0A'
   14     7      > FE_RESET_R                                       $3      !0, ->17
          8    > > FE_FETCH_R                                               $3, !1, ->17
   15     9    >   ECHO                                                     'Inner+foreach%3A+'
         10        INIT_FCALL                                               'memory_get_usage'
         11        SEND_VAL                                                 <true>
         12        DO_ICALL                                         $4      
         13        ECHO                                                     $4
         14        ECHO                                                     '%0A'
   16    15      > JMP                                                      ->17
   14    16*       JMP                                                      ->8
         17    >   FE_FREE                                                  $3
   18    18      > RETURN                                                   null

End of function by_value

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.53 ms | 1019 KiB | 17 Q