3v4l.org

run code in 500+ 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 = 29
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 29
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
Branch analysis from position: 6
Found catch point at position: 24
Branch analysis from position: 24
2 jumps found. (Code = 107) Position 1 = 25, Position 2 = -2
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
filename:       /in/LPetC
function name:  (null)
number of ops:  34
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, ->29
         19    > > FE_FETCH_R                                           ~14     $13, !2, ->29
         20    >   ASSIGN                                                       !3, ~14
   31    21        FRAMELESS_ICALL_2                str_contains        ~16     !2, 'test'
         22        ASSIGN                                                       !4, ~16
         23      > JMP                                                          ->26
   33    24  E > > CATCH                                           last         'Error'
   35    25    >   ASSIGN                                                       !4, 'Fatal+error+triggered'
   39    26    >   ASSIGN_DIM                                                   !1, !3
         27        OP_DATA                                                      !4
   27    28      > JMP                                                          ->19
         29    >   FE_FREE                                                      $13
   42    30        INIT_FCALL                                                   'var_export'
         31        SEND_VAR                                                     !1
         32        DO_ICALL                                                     
         33      > 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 = 7
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/LPetC
function name:  str_contains
number of ops:  11
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, ->7
          4    >   FRAMELESS_ICALL_2                strpos              ~3      !0, !1
          5        TYPE_CHECK                                      1018  ~4      ~3
          6        BOOL                                                 ~2      ~4
          7    >   VERIFY_RETURN_TYPE                                           ~2
          8      > RETURN                                                       ~2
    7     9*       VERIFY_RETURN_TYPE                                           
         10*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
1186.26 ms | 2205 KiB | 15 Q