3v4l.org

run code in 300+ PHP versions simultaneously
<?php $haystack = "I like cats."; $needles = ['cat' => 0, 'dog' => 1]; function earlyReturn(string $haystack, array $needles) { foreach ($needles as $needle => $value) { if (strpos($haystack, $needle) !== false) { return $value; } } throw new Exception('No needles were found in the haystack'); } try { var_export(earlyReturn($haystack, $needles)); } catch (Exception $e) { echo $e->getMessage(); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 10
Branch analysis from position: 10
2 jumps found. (Code = 107) Position 1 = 11, Position 2 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lbMTC
function name:  (null)
number of ops:  15
compiled vars:  !0 = $haystack, !1 = $needles, !2 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'I+like+cats.'
    4     1        ASSIGN                                                   !1, <array>
   15     2        INIT_FCALL                                               'var_export'
          3        INIT_FCALL                                               'earlyreturn'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_FCALL                                      0  $5      
          7        SEND_VAR                                                 $5
          8        DO_ICALL                                                 
          9      > JMP                                                      ->14
   16    10  E > > CATCH                                       last         'Exception'
   17    11    >   INIT_METHOD_CALL                                         !2, 'getMessage'
         12        DO_FCALL                                      0  $7      
         13        ECHO                                                     $7
   18    14    > > RETURN                                                   1

Function earlyreturn:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 14
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 14
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 14
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 14
filename:       /in/lbMTC
function name:  earlyReturn
number of ops:  20
compiled vars:  !0 = $haystack, !1 = $needles, !2 = $value, !3 = $needle
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2      > FE_RESET_R                                       $4      !1, ->14
          3    > > FE_FETCH_R                                       ~5      $4, !2, ->14
          4    >   ASSIGN                                                   !3, ~5
    8     5        INIT_FCALL                                               'strpos'
          6        SEND_VAR                                                 !0
          7        SEND_VAR                                                 !3
          8        DO_ICALL                                         $7      
          9        TYPE_CHECK                                  1018          $7
         10      > JMPZ                                                     ~8, ->13
    9    11    >   FE_FREE                                                  $4
         12      > RETURN                                                   !2
    7    13    > > JMP                                                      ->3
         14    >   FE_FREE                                                  $4
   12    15        NEW                                              $9      'Exception'
         16        SEND_VAL_EX                                              'No+needles+were+found+in+the+haystack'
         17        DO_FCALL                                      0          
         18      > THROW                                         0          $9
   13    19*     > RETURN                                                   null

End of function earlyreturn

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
134.3 ms | 1407 KiB | 18 Q