3v4l.org

run code in 300+ PHP versions simultaneously
<?php Class User extends Model { } class Model { public static function get() { // $records grabbed from db as associative array // key is id, value is StdClass instance $records = array( (object)array('name' => 'vic'), (object)array('name' => 'bob'), ); $ret = array(); foreach($records as $id=>$record) { print $record->name; // <--- FIRST PRINT LINE $class = get_called_class(); print $class; $new = new $class; $new->name = $record->name; $ret[] = $new; } return $ret; } } print "\n"; $users = User::get(); foreach($users as $id=>$user) { print $user->name; // <--- SECOND PRINT LINE }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 11
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/mAVdN
function name:  (null)
number of ops:  13
compiled vars:  !0 = $users, !1 = $user, !2 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   DECLARE_CLASS                                            'user', 'model'
   29     1        ECHO                                                     '%0A'
   31     2        INIT_STATIC_METHOD_CALL                                  'User', 'get'
          3        DO_FCALL                                      0  $3      
          4        ASSIGN                                                   !0, $3
   32     5      > FE_RESET_R                                       $5      !0, ->11
          6    > > FE_FETCH_R                                       ~6      $5, !1, ->11
          7    >   ASSIGN                                                   !2, ~6
   33     8        FETCH_OBJ_R                                      ~8      !1, 'name'
          9        ECHO                                                     ~8
   32    10      > JMP                                                      ->6
         11    >   FE_FREE                                                  $5
   34    12      > RETURN                                                   1

Class User: [no user functions]
Class Model:
Function get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 24
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 24
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/mAVdN
function name:  get
number of ops:  27
compiled vars:  !0 = $records, !1 = $ret, !2 = $record, !3 = $id, !4 = $class, !5 = $new
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   CAST                                          8  ~6      <array>
          1        INIT_ARRAY                                       ~7      ~6
   14     2        CAST                                          8  ~8      <array>
          3        ADD_ARRAY_ELEMENT                                ~7      ~8
   12     4        ASSIGN                                                   !0, ~7
   16     5        ASSIGN                                                   !1, <array>
   17     6      > FE_RESET_R                                       $11     !0, ->24
          7    > > FE_FETCH_R                                       ~12     $11, !2, ->24
          8    >   ASSIGN                                                   !3, ~12
   18     9        FETCH_OBJ_R                                      ~14     !2, 'name'
         10        ECHO                                                     ~14
   19    11        GET_CALLED_CLASS                                 ~15     
         12        ASSIGN                                                   !4, ~15
   20    13        ECHO                                                     !4
   21    14        FETCH_CLASS                                   0  $17     !4
         15        NEW                                              $18     $17
         16        DO_FCALL                                      0          
         17        ASSIGN                                                   !5, $18
   22    18        FETCH_OBJ_R                                      ~22     !2, 'name'
         19        ASSIGN_OBJ                                               !5, 'name'
         20        OP_DATA                                                  ~22
   23    21        ASSIGN_DIM                                               !1
         22        OP_DATA                                                  !5
   17    23      > JMP                                                      ->7
         24    >   FE_FREE                                                  $11
   25    25      > RETURN                                                   !1
   26    26*     > RETURN                                                   null

End of function get

End of class Model.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.67 ms | 1399 KiB | 13 Q