3v4l.org

run code in 300+ PHP versions simultaneously
<?php class product { public function getData($key){ return ['total' => rand(1,999)]; } } class Mage { public static function getModel($name){ $class = __CLASS__; return new $class; } public function load($id){ return new product; } } class item { public function getProductId(){ return rand(1, 999); } } class order { public function getAllItems(){ return [new item, new item, new item]; } } $order = new order; $totalprofit = 0; foreach($order->getAllItems() as $item): $product = Mage::getModel('catalog/product')->load($item->getProductId()); $profit = $product->getData('profit'); $totalprofit += $profit['total']; echo $profit['total'], "\n"; endforeach; echo $totalprofit, "\n"; ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 27
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 27
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/o5CVY
function name:  (null)
number of ops:  31
compiled vars:  !0 = $order, !1 = $totalprofit, !2 = $item, !3 = $product, !4 = $profit
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   NEW                                              $5      'order'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $5
   32     3        ASSIGN                                                   !1, 0
   33     4        INIT_METHOD_CALL                                         !0, 'getAllItems'
          5        DO_FCALL                                      0  $9      
          6      > FE_RESET_R                                       $10     $9, ->27
          7    > > FE_FETCH_R                                               $10, !2, ->27
   34     8    >   INIT_STATIC_METHOD_CALL                                  'Mage', 'getModel'
          9        SEND_VAL                                                 'catalog%2Fproduct'
         10        DO_FCALL                                      0  $11     
         11        INIT_METHOD_CALL                                         $11, 'load'
         12        INIT_METHOD_CALL                                         !2, 'getProductId'
         13        DO_FCALL                                      0  $12     
         14        SEND_VAR_NO_REF_EX                                       $12
         15        DO_FCALL                                      0  $13     
         16        ASSIGN                                                   !3, $13
   35    17        INIT_METHOD_CALL                                         !3, 'getData'
         18        SEND_VAL_EX                                              'profit'
         19        DO_FCALL                                      0  $15     
         20        ASSIGN                                                   !4, $15
   36    21        FETCH_DIM_R                                      ~17     !4, 'total'
         22        ASSIGN_OP                                     1          !1, ~17
   37    23        FETCH_DIM_R                                      ~19     !4, 'total'
         24        ECHO                                                     ~19
         25        ECHO                                                     '%0A'
   33    26      > JMP                                                      ->7
         27    >   FE_FREE                                                  $10
   39    28        ECHO                                                     !1
         29        ECHO                                                     '%0A'
   40    30      > RETURN                                                   1

Class product:
Function getdata:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/o5CVY
function name:  getData
number of ops:  8
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'rand'
          2        SEND_VAL                                                 1
          3        SEND_VAL                                                 999
          4        DO_ICALL                                         $1      
          5        INIT_ARRAY                                       ~2      $1, 'total'
          6      > RETURN                                                   ~2
    6     7*     > RETURN                                                   null

End of function getdata

End of class product.

Class Mage:
Function getmodel:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/o5CVY
function name:  getModel
number of ops:  7
compiled vars:  !0 = $name, !1 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        ASSIGN                                                   !1, 'Mage'
   12     2        FETCH_CLASS                                   0  $3      !1
          3        NEW                                              $4      $3
          4        DO_FCALL                                      0          
          5      > RETURN                                                   $4
   13     6*     > RETURN                                                   null

End of function getmodel

Function load:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/o5CVY
function name:  load
number of ops:  5
compiled vars:  !0 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        NEW                                              $1      'product'
          2        DO_FCALL                                      0          
          3      > RETURN                                                   $1
   16     4*     > RETURN                                                   null

End of function load

End of class Mage.

Class item:
Function getproductid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/o5CVY
function name:  getProductId
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_FCALL                                               'rand'
          1        SEND_VAL                                                 1
          2        SEND_VAL                                                 999
          3        DO_ICALL                                         $0      
          4      > RETURN                                                   $0
   22     5*     > RETURN                                                   null

End of function getproductid

End of class item.

Class order:
Function getallitems:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/o5CVY
function name:  getAllItems
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   NEW                                              $0      'item'
          1        DO_FCALL                                      0          
          2        INIT_ARRAY                                       ~2      $0
          3        NEW                                              $3      'item'
          4        DO_FCALL                                      0          
          5        ADD_ARRAY_ELEMENT                                ~2      $3
          6        NEW                                              $5      'item'
          7        DO_FCALL                                      0          
          8        ADD_ARRAY_ELEMENT                                ~2      $5
          9      > RETURN                                                   ~2
   28    10*     > RETURN                                                   null

End of function getallitems

End of class order.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.17 ms | 949 KiB | 16 Q