3v4l.org

run code in 300+ PHP versions simultaneously
<?php $priceChart = (object) [ 'Monday' => function($price) { return (int) $price / 2; }, 'Wednesday' => function($price) { return (int) $price * 1.1; }, 'Friday' => function($price) { return (int) $price > 200 ? (int) $price - 20 : (int) $price; } ]; $price = 20.00; $currentDay = 'Wednesday'; $newPrice = isset($priceChart->{$currentDay}) ? call_user_func_array($priceChart->{$currentDay}, [$price]) : $price; echo $newPrice;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 20
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AAQ86
function name:  (null)
number of ops:  24
compiled vars:  !0 = $priceChart, !1 = $price, !2 = $currentDay, !3 = $newPrice
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   DECLARE_LAMBDA_FUNCTION                          ~4      [0]
    7     1        INIT_ARRAY                                       ~5      ~4, 'Monday'
    8     2        DECLARE_LAMBDA_FUNCTION                          ~6      [1]
   10     3        ADD_ARRAY_ELEMENT                                ~5      ~6, 'Wednesday'
   11     4        DECLARE_LAMBDA_FUNCTION                          ~7      [2]
   13     5        ADD_ARRAY_ELEMENT                                ~5      ~7, 'Friday'
          6        CAST                                          8  ~8      ~5
    3     7        ASSIGN                                                   !0, ~8
   16     8        ASSIGN                                                   !1, 20
   17     9        ASSIGN                                                   !2, 'Wednesday'
   18    10        ISSET_ISEMPTY_PROP_OBJ                                   !0, !2
         11      > JMPZ                                                     ~12, ->20
         12    >   FETCH_OBJ_R                                      ~13     !0, !2
         13        INIT_USER_CALL                                0          'call_user_func_array', ~13
         14        INIT_ARRAY                                       ~14     !1
         15        SEND_ARRAY                                               ~14
         16        CHECK_UNDEF_ARGS                                         
         17        DO_FCALL                                      1  $15     
         18        QM_ASSIGN                                        ~16     $15
         19      > JMP                                                      ->21
         20    >   QM_ASSIGN                                        ~16     !1
         21    >   ASSIGN                                                   !3, ~16
   20    22        ECHO                                                     !3
   21    23      > 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/AAQ86
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $price
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        CAST                                          4  ~1      !0
          2        DIV                                              ~2      ~1, 2
          3      > RETURN                                                   ~2
    7     4*     > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AAQ86
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $price
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        CAST                                          4  ~1      !0
          2        MUL                                              ~2      ~1, 1.1
          3      > RETURN                                                   ~2
   10     4*     > RETURN                                                   null

End of Dynamic Function 1

Dynamic Function 2
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AAQ86
function name:  {closure}
number of ops:  12
compiled vars:  !0 = $price
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        CAST                                          4  ~1      !0
          2        IS_SMALLER                                               200, ~1
          3      > JMPZ                                                     ~2, ->8
          4    >   CAST                                          4  ~3      !0
          5        SUB                                              ~4      ~3, 20
          6        QM_ASSIGN                                        ~5      ~4
          7      > JMP                                                      ->10
          8    >   CAST                                          4  ~6      !0
          9        QM_ASSIGN                                        ~5      ~6
         10    > > RETURN                                                   ~5
   13    11*     > RETURN                                                   null

End of Dynamic Function 2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
263.78 ms | 1007 KiB | 13 Q