3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function add($val = 0) { $this->stuff[] = $val; } } $x = new Foo(); $x->add(42); echo serialize($x) . "\n"; var_dump($x); echo "\n\n"; class Bar { private $stuff = []; public function add($x = 0) { $this->stuff[] = $x; } } $x = new Bar(); $x->add(42); echo serialize($x) . "\n"; var_dump($x);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fCs2s
function name:  (null)
number of ops:  30
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   NEW                                              $1      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   10     3        INIT_METHOD_CALL                                         !0, 'add'
          4        SEND_VAL_EX                                              42
          5        DO_FCALL                                      0          
   11     6        INIT_FCALL                                               'serialize'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $5      
          9        CONCAT                                           ~6      $5, '%0A'
         10        ECHO                                                     ~6
   12    11        INIT_FCALL                                               'var_dump'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                                 
   14    14        ECHO                                                     '%0A%0A'
   23    15        NEW                                              $8      'Bar'
         16        DO_FCALL                                      0          
         17        ASSIGN                                                   !0, $8
   24    18        INIT_METHOD_CALL                                         !0, 'add'
         19        SEND_VAL_EX                                              42
         20        DO_FCALL                                      0          
   25    21        INIT_FCALL                                               'serialize'
         22        SEND_VAR                                                 !0
         23        DO_ICALL                                         $12     
         24        CONCAT                                           ~13     $12, '%0A'
         25        ECHO                                                     ~13
   26    26        INIT_FCALL                                               'var_dump'
         27        SEND_VAR                                                 !0
         28        DO_ICALL                                                 
         29      > RETURN                                                   1

Class Foo:
Function add:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fCs2s
function name:  add
number of ops:  5
compiled vars:  !0 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV_INIT                                        !0      0
    5     1        FETCH_OBJ_W                                      $1      'stuff'
          2        ASSIGN_DIM                                               $1
          3        OP_DATA                                                  !0
    6     4      > RETURN                                                   null

End of function add

End of class Foo.

Class Bar:
Function add:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fCs2s
function name:  add
number of ops:  5
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV_INIT                                        !0      0
   19     1        FETCH_OBJ_W                                      $1      'stuff'
          2        ASSIGN_DIM                                               $1
          3        OP_DATA                                                  !0
   20     4      > RETURN                                                   null

End of function add

End of class Bar.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
130.04 ms | 1405 KiB | 17 Q