3v4l.org

run code in 300+ PHP versions simultaneously
<?php if (!function_exists('str_contains')) { function str_contains(string $haystack, string $needle): bool { return '' === $needle || false !== strpos($haystack, $needle); } }; $types = [ 'string' => 'test', 'int' => 1, 'float' => 1.23, 'null' => null, 'true' => true, 'false' => false, 'object' => new StdClass(), 'array' => [], ]; $result = [ ]; foreach($types as $type => $val) { try { $res = str_contains($val, 'test'); } catch (Error $e) { $res = 'Fatal error triggered'; } $result[$type] = $res; } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 32
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 32
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
Branch analysis from position: 6
Found catch point at position: 27
Branch analysis from position: 27
2 jumps found. (Code = 107) Position 1 = 28, Position 2 = -2
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
filename:       /in/LPetC
function name:  (null)
number of ops:  37
compiled vars:  !0 = $types, !1 = $result, !2 = $val, !3 = $type, !4 = $res, !5 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'function_exists'
          1        SEND_VAL                                                 'str_contains'
          2        DO_ICALL                                         $6      
          3        BOOL_NOT                                         ~7      $6
          4      > JMPZ                                                     ~7, ->6
    4     5    >   DECLARE_FUNCTION                                         'str_contains'
   13     6    >   INIT_ARRAY                                       ~8      'test', 'string'
   14     7        ADD_ARRAY_ELEMENT                                ~8      1, 'int'
   15     8        ADD_ARRAY_ELEMENT                                ~8      1.23, 'float'
   13     9        ADD_ARRAY_ELEMENT                                ~8      null, 'null'
         10        ADD_ARRAY_ELEMENT                                ~8      <true>, 'true'
         11        ADD_ARRAY_ELEMENT                                ~8      <false>, 'false'
   19    12        NEW                                              $9      'StdClass'
         13        DO_FCALL                                      0          
         14        ADD_ARRAY_ELEMENT                                ~8      $9, 'object'
   13    15        ADD_ARRAY_ELEMENT                                ~8      <array>, 'array'
   12    16        ASSIGN                                                   !0, ~8
   23    17        ASSIGN                                                   !1, <array>
   27    18      > FE_RESET_R                                       $13     !0, ->32
         19    > > FE_FETCH_R                                       ~14     $13, !2, ->32
         20    >   ASSIGN                                                   !3, ~14
   31    21        INIT_FCALL                                               'str_contains'
         22        SEND_VAR                                                 !2
         23        SEND_VAL                                                 'test'
         24        DO_ICALL                                         $16     
         25        ASSIGN                                                   !4, $16
         26      > JMP                                                      ->29
   33    27  E > > CATCH                                       last         'Error'
   35    28    >   ASSIGN                                                   !4, 'Fatal+error+triggered'
   39    29    >   ASSIGN_DIM                                               !1, !3
         30        OP_DATA                                                  !4
   27    31      > JMP                                                      ->19
         32    >   FE_FREE                                                  $13
   42    33        INIT_FCALL                                               'var_export'
         34        SEND_VAR                                                 !1
         35        DO_ICALL                                                 
         36      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/LPetC
function name:  str_contains
number of ops:  14
compiled vars:  !0 = $haystack, !1 = $needle
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        IS_IDENTICAL                                     ~2      !1, ''
          3      > JMPNZ_EX                                         ~2      ~2, ->10
          4    >   INIT_FCALL                                               'strpos'
          5        SEND_VAR                                                 !0
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $3      
          8        TYPE_CHECK                                  1018  ~4      $3
          9        BOOL                                             ~2      ~4
         10    >   VERIFY_RETURN_TYPE                                       ~2
         11      > RETURN                                                   ~2
    7    12*       VERIFY_RETURN_TYPE                                       
         13*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.4 ms | 1461 KiB | 17 Q