3v4l.org

run code in 300+ PHP versions simultaneously
<?php $values = [1 => 'a', 2 => 'b', 3 => 'c']; $defaultValue = 'd'; function krasivo(array $values, int $number, string $defaultValue = null) { return $values[$number] ?? $defaultValue ?? 'value not found'; } function kal(array $values, int $number, string $defaultValue = null) { if (array_key_exists($number, $values)) { return $values[$number]; } elseif($defaultValue) { return $defaultValue; } else { return 'value not found'; } } echo krasivo($values, 1) . PHP_EOL; echo kal($values, 4) . PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iFS8B
function name:  (null)
number of ops:  15
compiled vars:  !0 = $values, !1 = $defaultValue
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, 'd'
   20     2        INIT_FCALL                                               'krasivo'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 1
          5        DO_FCALL                                      0  $4      
          6        CONCAT                                           ~5      $4, '%0A'
          7        ECHO                                                     ~5
   21     8        INIT_FCALL                                               'kal'
          9        SEND_VAR                                                 !0
         10        SEND_VAL                                                 4
         11        DO_FCALL                                      0  $6      
         12        CONCAT                                           ~7      $6, '%0A'
         13        ECHO                                                     ~7
   22    14      > RETURN                                                   1

Function krasivo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iFS8B
function name:  krasivo
number of ops:  10
compiled vars:  !0 = $values, !1 = $number, !2 = $defaultValue
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      null
    7     3        FETCH_DIM_IS                                     ~3      !0, !1
          4        COALESCE                                         ~4      ~3
          5        COALESCE                                         ~5      !2
          6        QM_ASSIGN                                        ~5      'value+not+found'
          7        QM_ASSIGN                                        ~4      ~5
          8      > RETURN                                                   ~4
    8     9*     > RETURN                                                   null

End of function krasivo

Function kal:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iFS8B
function name:  kal
number of ops:  13
compiled vars:  !0 = $values, !1 = $number, !2 = $defaultValue
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      null
   11     3        ARRAY_KEY_EXISTS                                         !1, !0
          4      > JMPZ                                                     ~3, ->8
   12     5    >   FETCH_DIM_R                                      ~4      !0, !1
          6      > RETURN                                                   ~4
   11     7*       JMP                                                      ->12
   13     8    > > JMPZ                                                     !2, ->11
   14     9    > > RETURN                                                   !2
   13    10*       JMP                                                      ->12
   16    11    > > RETURN                                                   'value+not+found'
   18    12*     > RETURN                                                   null

End of function kal

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.25 ms | 1003 KiB | 15 Q