3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public $foo = 1; protected $bar = 2; private $baz = 3; public function toArray() { $arr = array(); foreach ($this as $k => $v) { $arr[$k] = $v; } return $arr; } } $foo = new Foo; $a1 = (array)$foo; $a2 = $foo->toArray(); $a3 = array(); foreach ($foo as $k => $v) { $a3[$k] = $v; } var_dump($a1, $a2, $a3); // unrelated fun: var_dump($a1['*bar']); var_dump($a1['Foobaz']);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 15
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 15
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/vT2Fl
function name:  (null)
number of ops:  30
compiled vars:  !0 = $foo, !1 = $a1, !2 = $a2, !3 = $a3, !4 = $v, !5 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   NEW                                              $6      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $6
   17     3        CAST                                          7  ~9      !0
          4        ASSIGN                                                   !1, ~9
   18     5        INIT_METHOD_CALL                                         !0, 'toArray'
          6        DO_FCALL                                      0  $11     
          7        ASSIGN                                                   !2, $11
   19     8        ASSIGN                                                   !3, <array>
   20     9      > FE_RESET_R                                       $14     !0, ->15
         10    > > FE_FETCH_R                                       ~15     $14, !4, ->15
         11    >   ASSIGN                                                   !5, ~15
   21    12        ASSIGN_DIM                                               !3, !5
         13        OP_DATA                                                  !4
   20    14      > JMP                                                      ->10
         15    >   FE_FREE                                                  $14
   24    16        INIT_FCALL                                               'var_dump'
         17        SEND_VAR                                                 !1
         18        SEND_VAR                                                 !2
         19        SEND_VAR                                                 !3
         20        DO_ICALL                                                 
   27    21        INIT_FCALL                                               'var_dump'
         22        FETCH_DIM_R                                      ~19     !1, '%2Abar'
         23        SEND_VAL                                                 ~19
         24        DO_ICALL                                                 
   28    25        INIT_FCALL                                               'var_dump'
         26        FETCH_DIM_R                                      ~21     !1, 'Foobaz'
         27        SEND_VAL                                                 ~21
         28        DO_ICALL                                                 
         29      > RETURN                                                   1

Class Foo:
Function toarray:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 8
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/vT2Fl
function name:  toArray
number of ops:  11
compiled vars:  !0 = $arr, !1 = $v, !2 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ASSIGN                                                   !0, <array>
   10     1        FETCH_THIS                                       ~4      
          2      > FE_RESET_R                                       $5      ~4, ->8
          3    > > FE_FETCH_R                                       ~6      $5, !1, ->8
          4    >   ASSIGN                                                   !2, ~6
   11     5        ASSIGN_DIM                                               !0, !2
          6        OP_DATA                                                  !1
   10     7      > JMP                                                      ->3
          8    >   FE_FREE                                                  $5
   13     9      > RETURN                                                   !0
   14    10*     > RETURN                                                   null

End of function toarray

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.67 ms | 1400 KiB | 15 Q