3v4l.org

run code in 300+ PHP versions simultaneously
<?php function str_is($pattern, $value) { $patterns = is_array($pattern) ? $pattern : (array) $pattern; if (empty($patterns)) { return false; } foreach ($patterns as $pattern) { // If the given value is an exact match we can of course return true right // from the beginning. Otherwise, we will translate asterisks and do an // actual pattern match against the two strings to see if they match. if ($pattern == $value) { return true; } $pattern = preg_quote($pattern, '#'); var_dump($pattern); // Asterisks are translated into zero-or-more regular expression wildcards // to make it convenient to check if the strings starts with the given // pattern such as "library/*", making any string check convenient. $pattern = str_replace('\*', '.*', $pattern); if (preg_match('#^'.$pattern.'\z#u', $value) === 1) { return true; } } return false; } $result = preg_match('/[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}/i', '5d8977f1-8809-47b0-a01d-492373fd81c6'); $resultLaravel = str_is('[a-z]', '5d8977f1-8809-47b0-a01d-492373fd81c6'); var_dump($result, $resultLaravel);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fEBKL
function name:  (null)
number of ops:  15
compiled vars:  !0 = $result, !1 = $resultLaravel
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   INIT_FCALL                                               'preg_match'
          1        SEND_VAL                                                 '%2F%5Ba-f0-9%5D%7B8%7D-%3F%5Ba-f0-9%5D%7B4%7D-%3F4%5Ba-f0-9%5D%7B3%7D-%3F%5B89ab%5D%5Ba-f0-9%5D%7B3%7D-%3F%5Ba-f0-9%5D%7B12%7D%2Fi'
          2        SEND_VAL                                                 '5d8977f1-8809-47b0-a01d-492373fd81c6'
          3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !0, $2
   38     5        INIT_FCALL                                               'str_is'
          6        SEND_VAL                                                 '%5Ba-z%5D'
          7        SEND_VAL                                                 '5d8977f1-8809-47b0-a01d-492373fd81c6'
          8        DO_FCALL                                      0  $4      
          9        ASSIGN                                                   !1, $4
   40    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !0
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Function str_is:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 12
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 43
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 43
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 42
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 12
Branch analysis from position: 11
Branch analysis from position: 12
filename:       /in/fEBKL
function name:  str_is
number of ops:  46
compiled vars:  !0 = $pattern, !1 = $value, !2 = $patterns
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        TYPE_CHECK                                  128          !0
          3      > JMPZ                                                     ~3, ->6
          4    >   QM_ASSIGN                                        ~4      !0
          5      > JMP                                                      ->8
          6    >   CAST                                          7  ~5      !0
          7        QM_ASSIGN                                        ~4      ~5
          8    >   ASSIGN                                                   !2, ~4
    8     9        ISSET_ISEMPTY_CV                                         !2
         10      > JMPZ                                                     ~7, ->12
    9    11    > > RETURN                                                   <false>
   12    12    > > FE_RESET_R                                       $8      !2, ->43
         13    > > FE_FETCH_R                                               $8, !0, ->43
   16    14    >   IS_EQUAL                                                 !0, !1
         15      > JMPZ                                                     ~9, ->18
   17    16    >   FE_FREE                                                  $8
         17      > RETURN                                                   <true>
   20    18    >   INIT_FCALL                                               'preg_quote'
         19        SEND_VAR                                                 !0
         20        SEND_VAL                                                 '%23'
         21        DO_ICALL                                         $10     
         22        ASSIGN                                                   !0, $10
   22    23        INIT_FCALL                                               'var_dump'
         24        SEND_VAR                                                 !0
         25        DO_ICALL                                                 
   27    26        INIT_FCALL                                               'str_replace'
         27        SEND_VAL                                                 '%5C%2A'
         28        SEND_VAL                                                 '.%2A'
         29        SEND_VAR                                                 !0
         30        DO_ICALL                                         $13     
         31        ASSIGN                                                   !0, $13
   29    32        INIT_FCALL                                               'preg_match'
         33        CONCAT                                           ~15     '%23%5E', !0
         34        CONCAT                                           ~16     ~15, '%5Cz%23u'
         35        SEND_VAL                                                 ~16
         36        SEND_VAR                                                 !1
         37        DO_ICALL                                         $17     
         38        IS_IDENTICAL                                             $17, 1
         39      > JMPZ                                                     ~18, ->42
   30    40    >   FE_FREE                                                  $8
         41      > RETURN                                                   <true>
   12    42    > > JMP                                                      ->13
         43    >   FE_FREE                                                  $8
   34    44      > RETURN                                                   <false>
   35    45*     > RETURN                                                   null

End of function str_is

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.39 ms | 1407 KiB | 22 Q