3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Item { private $id; private $name; function __construct(int $id, string $name) { $this->id = $id; $this->name = $name; } public function __get($prop) { return $this->$prop; } } $itemList = [ new Item(1, "Item 1"), new Item(2, "Item 2"), new Item(3, "Item 3"), new Item(4, "Item 4") ]; echo implode(',', array_map(fn($obj) => $obj->id, $itemList)); echo "\n---\n"; echo array_reduce( $itemList, fn($result, $obj) => $result . ($result ? ',' : '') . $obj->id );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PBtHA
function name:  (null)
number of ops:  39
compiled vars:  !0 = $itemList
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   NEW                                              $1      'Item'
          1        SEND_VAL_EX                                              1
          2        SEND_VAL_EX                                              'Item+1'
          3        DO_FCALL                                      0          
          4        INIT_ARRAY                                       ~3      $1
   21     5        NEW                                              $4      'Item'
          6        SEND_VAL_EX                                              2
          7        SEND_VAL_EX                                              'Item+2'
          8        DO_FCALL                                      0          
          9        ADD_ARRAY_ELEMENT                                ~3      $4
   22    10        NEW                                              $6      'Item'
         11        SEND_VAL_EX                                              3
         12        SEND_VAL_EX                                              'Item+3'
         13        DO_FCALL                                      0          
         14        ADD_ARRAY_ELEMENT                                ~3      $6
   23    15        NEW                                              $8      'Item'
         16        SEND_VAL_EX                                              4
         17        SEND_VAL_EX                                              'Item+4'
         18        DO_FCALL                                      0          
         19        ADD_ARRAY_ELEMENT                                ~3      $8
   19    20        ASSIGN                                                   !0, ~3
   27    21        INIT_FCALL                                               'implode'
         22        SEND_VAL                                                 '%2C'
         23        INIT_FCALL                                               'array_map'
         24        DECLARE_LAMBDA_FUNCTION                          ~11     [0]
         25        SEND_VAL                                                 ~11
         26        SEND_VAR                                                 !0
         27        DO_ICALL                                         $12     
         28        SEND_VAR                                                 $12
         29        DO_ICALL                                         $13     
         30        ECHO                                                     $13
   29    31        ECHO                                                     '%0A---%0A'
   31    32        INIT_FCALL                                               'array_reduce'
   32    33        SEND_VAR                                                 !0
   33    34        DECLARE_LAMBDA_FUNCTION                          ~14     [1]
   34    35        SEND_VAL                                                 ~14
   31    36        DO_ICALL                                         $15     
   34    37        ECHO                                                     $15
         38      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PBtHA
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
          1        FETCH_OBJ_R                                      ~1      !0, 'id'
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PBtHA
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $result, !1 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2      > JMPZ                                                     !0, ->5
          3    >   QM_ASSIGN                                        ~2      '%2C'
          4      > JMP                                                      ->6
          5    >   QM_ASSIGN                                        ~2      ''
          6    >   CONCAT                                           ~3      !0, ~2
          7        FETCH_OBJ_R                                      ~4      !1, 'id'
          8        CONCAT                                           ~5      ~3, ~4
          9      > RETURN                                                   ~5
   34    10*     > RETURN                                                   null

End of Dynamic Function 1

Class Item:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PBtHA
function name:  __construct
number of ops:  7
compiled vars:  !0 = $id, !1 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    9     2        ASSIGN_OBJ                                               'id'
          3        OP_DATA                                                  !0
   10     4        ASSIGN_OBJ                                               'name'
          5        OP_DATA                                                  !1
   11     6      > RETURN                                                   null

End of function __construct

Function __get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PBtHA
function name:  __get
number of ops:  4
compiled vars:  !0 = $prop
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   15     1        FETCH_OBJ_R                                      ~1      !0
          2      > RETURN                                                   ~1
   16     3*     > RETURN                                                   null

End of function __get

End of class Item.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.43 ms | 1005 KiB | 16 Q