3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = "foo"; $b = str_repeat("a", 3); echo "Static Var\n"; testCopy($a); echo "Dynamic Var\n"; testCopy($b); function testCopy($var) { echo memory_get_usage() . "\n"; $b = (string) $var; echo memory_get_usage() . "\n"; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1bM8L
function name:  (null)
number of ops:  15
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'foo'
    4     1        INIT_FCALL                                               'str_repeat'
          2        SEND_VAL                                                 'a'
          3        SEND_VAL                                                 3
          4        DO_ICALL                                         $3      
          5        ASSIGN                                                   !1, $3
    5     6        ECHO                                                     'Static+Var%0A'
    6     7        INIT_FCALL_BY_NAME                                       'testCopy'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0          
    7    10        ECHO                                                     'Dynamic+Var%0A'
    8    11        INIT_FCALL_BY_NAME                                       'testCopy'
         12        SEND_VAR_EX                                              !1
         13        DO_FCALL                                      0          
   14    14      > RETURN                                                   1

Function testcopy:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1bM8L
function name:  testCopy
number of ops:  12
compiled vars:  !0 = $var, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        INIT_FCALL                                               'memory_get_usage'
          2        DO_ICALL                                         $2      
          3        CONCAT                                           ~3      $2, '%0A'
          4        ECHO                                                     ~3
   12     5        CAST                                          6  ~4      !0
          6        ASSIGN                                                   !1, ~4
   13     7        INIT_FCALL                                               'memory_get_usage'
          8        DO_ICALL                                         $6      
          9        CONCAT                                           ~7      $6, '%0A'
         10        ECHO                                                     ~7
   14    11      > RETURN                                                   null

End of function testcopy

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.75 ms | 1395 KiB | 17 Q