3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* * preg_match() and //u pattern modifier * * @link https://stackoverflow.com/a/6723593/367456 */ $constants = function_exists('get_defined_constants') ? @get_defined_constants(true) : null; $pcreConstants = (array)@$constants['pcre']; $pcreConstants = null; if (empty($pcreConstants)) { $pcreConstants = array(); foreach (get_defined_constants() as $constant => $value) { if (6 === sscanf($constant, '%*[P]%*1[CR]%*1[RE]%*1[EG]%*[_]%n', $n)) { $pcreConstants[$constant] = $value; } } } $kMap = array_flip(array_keys($pcreConstants)); $ofVer = @$kMap['PCRE_VERSION']; $stop = $ofVer ? $ofVer : count($pcreConstants); $ofFirst = intval(@$kMap['PREG_NO_ERROR']); $errors = array_flip(array_slice($pcreConstants, $ofFirst, - $ofFirst + $stop)); $return = preg_match('//u', "\x80"); $matchesUTF8 = 1 === $return; $isMatchError = false === $return; $pregLastError = function_exists('preg_last_error') ? preg_last_error() : null; $pregLastErrorMsg = function_exists('preg_last_error_msg') ? preg_last_error_msg() : null; printf("\$return: %s\n", var_export($return, true)); printf("\$matchesUTF8: %s\n", var_export($matchesUTF8, true)); printf("\$isMatchError: %s\n", var_export($isMatchError, true)); printf("\$pregLastError: %s\n", var_export($pregLastError, true)); printf("\$pregLastErrorMsg: %s\n", var_export($pregLastErrorMsg, true)); printf("PREG_*_ERROR: %s\n", var_export(@$errors[$pregLastError], true)); printf("PCRE_VERSION: %s\n", @$pcreConstants['PCRE_VERSION']); $extPcreVer = function_exists('phpversion') ? @phpversion('pcre') : null; if ($extPcreVer === PHP_VERSION) $extPcreVer = 'PHP_VERSION'; printf("ext-pcre version: %s\n", var_export($extPcreVer, true)); echo 'pcre constants: ', print_r($pcreConstants, true);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 11
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 38
Branch analysis from position: 21
2 jumps found. (Code = 77) Position 1 = 25, Position 2 = 37
Branch analysis from position: 25
2 jumps found. (Code = 78) Position 1 = 26, Position 2 = 37
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 36
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 36
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 50, Position 2 = 52
Branch analysis from position: 50
1 jumps found. (Code = 42) Position 1 = 54
Branch analysis from position: 54
2 jumps found. (Code = 43) Position 1 = 84, Position 2 = 88
Branch analysis from position: 84
1 jumps found. (Code = 42) Position 1 = 89
Branch analysis from position: 89
2 jumps found. (Code = 43) Position 1 = 94, Position 2 = 98
Branch analysis from position: 94
1 jumps found. (Code = 42) Position 1 = 99
Branch analysis from position: 99
2 jumps found. (Code = 43) Position 1 = 162, Position 2 = 169
Branch analysis from position: 162
1 jumps found. (Code = 42) Position 1 = 170
Branch analysis from position: 170
2 jumps found. (Code = 43) Position 1 = 173, Position 2 = 174
Branch analysis from position: 173
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 174
Branch analysis from position: 169
2 jumps found. (Code = 43) Position 1 = 173, Position 2 = 174
Branch analysis from position: 173
Branch analysis from position: 174
Branch analysis from position: 98
2 jumps found. (Code = 43) Position 1 = 162, Position 2 = 169
Branch analysis from position: 162
Branch analysis from position: 169
Branch analysis from position: 88
2 jumps found. (Code = 43) Position 1 = 94, Position 2 = 98
Branch analysis from position: 94
Branch analysis from position: 98
Branch analysis from position: 52
2 jumps found. (Code = 43) Position 1 = 84, Position 2 = 88
Branch analysis from position: 84
Branch analysis from position: 88
Branch analysis from position: 37
Branch analysis from position: 38
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 38
Branch analysis from position: 21
Branch analysis from position: 38
filename:       /in/VYqIO
function name:  (null)
number of ops:  189
compiled vars:  !0 = $constants, !1 = $pcreConstants, !2 = $value, !3 = $constant, !4 = $n, !5 = $kMap, !6 = $ofVer, !7 = $stop, !8 = $ofFirst, !9 = $errors, !10 = $return, !11 = $matchesUTF8, !12 = $isMatchError, !13 = $pregLastError, !14 = $pregLastErrorMsg, !15 = $extPcreVer
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                               'function_exists'
          1        SEND_VAL                                                 'get_defined_constants'
          2        DO_ICALL                                         $16     
          3      > JMPZ                                                     $16, ->11
          4    >   BEGIN_SILENCE                                    ~17     
          5        INIT_FCALL                                               'get_defined_constants'
          6        SEND_VAL                                                 <true>
          7        DO_ICALL                                         $18     
          8        END_SILENCE                                              ~17
          9        QM_ASSIGN                                        ~19     $18
         10      > JMP                                                      ->12
         11    >   QM_ASSIGN                                        ~19     null
         12    >   ASSIGN                                                   !0, ~19
   10    13        BEGIN_SILENCE                                    ~21     
         14        FETCH_DIM_R                                      ~22     !0, 'pcre'
         15        END_SILENCE                                              ~21
         16        CAST                                          7  ~23     ~22
         17        ASSIGN                                                   !1, ~23
   11    18        ASSIGN                                                   !1, null
   12    19        ISSET_ISEMPTY_CV                                         !1
         20      > JMPZ                                                     ~26, ->38
   13    21    >   ASSIGN                                                   !1, <array>
   14    22        INIT_FCALL                                               'get_defined_constants'
         23        DO_ICALL                                         $28     
         24      > FE_RESET_R                                       $29     $28, ->37
         25    > > FE_FETCH_R                                       ~30     $29, !2, ->37
         26    >   ASSIGN                                                   !3, ~30
   16    27        INIT_FCALL                                               'sscanf'
         28        SEND_VAR                                                 !3
         29        SEND_VAL                                                 '%25%2A%5BP%5D%25%2A1%5BCR%5D%25%2A1%5BRE%5D%25%2A1%5BEG%5D%25%2A%5B_%5D%25n'
         30        SEND_REF                                                 !4
         31        DO_ICALL                                         $32     
         32        IS_IDENTICAL                                             $32, 6
         33      > JMPZ                                                     ~33, ->36
   17    34    >   ASSIGN_DIM                                               !1, !3
         35        OP_DATA                                                  !2
   14    36    > > JMP                                                      ->25
         37    >   FE_FREE                                                  $29
   22    38    >   INIT_FCALL                                               'array_flip'
         39        INIT_FCALL                                               'array_keys'
         40        SEND_VAR                                                 !1
         41        DO_ICALL                                         $35     
         42        SEND_VAR                                                 $35
         43        DO_ICALL                                         $36     
         44        ASSIGN                                                   !5, $36
   23    45        BEGIN_SILENCE                                    ~38     
         46        FETCH_DIM_R                                      ~39     !5, 'PCRE_VERSION'
         47        END_SILENCE                                              ~38
         48        ASSIGN                                                   !6, ~39
   24    49      > JMPZ                                                     !6, ->52
         50    >   QM_ASSIGN                                        ~41     !6
         51      > JMP                                                      ->54
         52    >   COUNT                                            ~42     !1
         53        QM_ASSIGN                                        ~41     ~42
         54    >   ASSIGN                                                   !7, ~41
   25    55        BEGIN_SILENCE                                    ~44     
         56        FETCH_DIM_R                                      ~45     !5, 'PREG_NO_ERROR'
         57        END_SILENCE                                              ~44
         58        CAST                                          4  ~46     ~45
         59        ASSIGN                                                   !8, ~46
   26    60        INIT_FCALL                                               'array_flip'
         61        INIT_FCALL                                               'array_slice'
         62        SEND_VAR                                                 !1
         63        SEND_VAR                                                 !8
         64        MUL                                              ~48     !8, -1
         65        ADD                                              ~49     ~48, !7
         66        SEND_VAL                                                 ~49
         67        DO_ICALL                                         $50     
         68        SEND_VAR                                                 $50
         69        DO_ICALL                                         $51     
         70        ASSIGN                                                   !9, $51
   28    71        INIT_FCALL                                               'preg_match'
         72        SEND_VAL                                                 '%2F%2Fu'
         73        SEND_VAL                                                 '%80'
         74        DO_ICALL                                         $53     
         75        ASSIGN                                                   !10, $53
   29    76        IS_IDENTICAL                                     ~55     !10, 1
         77        ASSIGN                                                   !11, ~55
   30    78        TYPE_CHECK                                    4  ~57     !10
         79        ASSIGN                                                   !12, ~57
   31    80        INIT_FCALL                                               'function_exists'
         81        SEND_VAL                                                 'preg_last_error'
         82        DO_ICALL                                         $59     
         83      > JMPZ                                                     $59, ->88
         84    >   INIT_FCALL                                               'preg_last_error'
         85        DO_ICALL                                         $60     
         86        QM_ASSIGN                                        ~61     $60
         87      > JMP                                                      ->89
         88    >   QM_ASSIGN                                        ~61     null
         89    >   ASSIGN                                                   !13, ~61
   32    90        INIT_FCALL                                               'function_exists'
         91        SEND_VAL                                                 'preg_last_error_msg'
         92        DO_ICALL                                         $63     
         93      > JMPZ                                                     $63, ->98
         94    >   INIT_FCALL                                               'preg_last_error_msg'
         95        DO_ICALL                                         $64     
         96        QM_ASSIGN                                        ~65     $64
         97      > JMP                                                      ->99
         98    >   QM_ASSIGN                                        ~65     null
         99    >   ASSIGN                                                   !14, ~65
   34   100        INIT_FCALL                                               'printf'
        101        SEND_VAL                                                 '%24return%3A+%25s%0A'
        102        INIT_FCALL                                               'var_export'
        103        SEND_VAR                                                 !10
        104        SEND_VAL                                                 <true>
        105        DO_ICALL                                         $67     
        106        SEND_VAR                                                 $67
        107        DO_ICALL                                                 
   35   108        INIT_FCALL                                               'printf'
        109        SEND_VAL                                                 '%24matchesUTF8%3A+%25s%0A'
        110        INIT_FCALL                                               'var_export'
        111        SEND_VAR                                                 !11
        112        SEND_VAL                                                 <true>
        113        DO_ICALL                                         $69     
        114        SEND_VAR                                                 $69
        115        DO_ICALL                                                 
   36   116        INIT_FCALL                                               'printf'
        117        SEND_VAL                                                 '%24isMatchError%3A+%25s%0A'
        118        INIT_FCALL                                               'var_export'
        119        SEND_VAR                                                 !12
        120        SEND_VAL                                                 <true>
        121        DO_ICALL                                         $71     
        122        SEND_VAR                                                 $71
        123        DO_ICALL                                                 
   37   124        INIT_FCALL                                               'printf'
        125        SEND_VAL                                                 '%24pregLastError%3A+%25s%0A'
        126        INIT_FCALL                                               'var_export'
        127        SEND_VAR                                                 !13
        128        SEND_VAL                                                 <true>
        129        DO_ICALL                                         $73     
        130        SEND_VAR                                                 $73
        131        DO_ICALL                                                 
   38   132        INIT_FCALL                                               'printf'
        133        SEND_VAL                                                 '%24pregLastErrorMsg%3A+%25s%0A'
        134        INIT_FCALL                                               'var_export'
        135        SEND_VAR                                                 !14
        136        SEND_VAL                                                 <true>
        137        DO_ICALL                                         $75     
        138        SEND_VAR                                                 $75
        139        DO_ICALL                                                 
   39   140        INIT_FCALL                                               'printf'
        141        SEND_VAL                                                 'PREG_%2A_ERROR%3A+%25s%0A'
        142        INIT_FCALL                                               'var_export'
        143        BEGIN_SILENCE                                    ~77     
        144        FETCH_DIM_R                                      ~78     !9, !13
        145        END_SILENCE                                              ~77
        146        SEND_VAL                                                 ~78
        147        SEND_VAL                                                 <true>
        148        DO_ICALL                                         $79     
        149        SEND_VAR                                                 $79
        150        DO_ICALL                                                 
   40   151        INIT_FCALL                                               'printf'
        152        SEND_VAL                                                 'PCRE_VERSION%3A+%25s%0A'
        153        BEGIN_SILENCE                                    ~81     
        154        FETCH_DIM_R                                      ~82     !1, 'PCRE_VERSION'
        155        END_SILENCE                                              ~81
        156        SEND_VAL                                                 ~82
        157        DO_ICALL                                                 
   41   158        INIT_FCALL                                               'function_exists'
        159        SEND_VAL                                                 'phpversion'
        160        DO_ICALL                                         $84     
        161      > JMPZ                                                     $84, ->169
        162    >   BEGIN_SILENCE                                    ~85     
        163        INIT_FCALL                                               'phpversion'
        164        SEND_VAL                                                 'pcre'
        165        DO_ICALL                                         $86     
        166        END_SILENCE                                              ~85
        167        QM_ASSIGN                                        ~87     $86
        168      > JMP                                                      ->170
        169    >   QM_ASSIGN                                        ~87     null
        170    >   ASSIGN                                                   !15, ~87
   42   171        IS_IDENTICAL                                             !15, '8.3.0'
        172      > JMPZ                                                     ~89, ->174
        173    >   ASSIGN                                                   !15, 'PHP_VERSION'
   43   174    >   INIT_FCALL                                               'printf'
        175        SEND_VAL                                                 'ext-pcre+version%3A+%25s%0A'
        176        INIT_FCALL                                               'var_export'
        177        SEND_VAR                                                 !15
        178        SEND_VAL                                                 <true>
        179        DO_ICALL                                         $91     
        180        SEND_VAR                                                 $91
        181        DO_ICALL                                                 
   44   182        ECHO                                                     'pcre+constants%3A+'
        183        INIT_FCALL                                               'print_r'
        184        SEND_VAR                                                 !1
        185        SEND_VAL                                                 <true>
        186        DO_ICALL                                         $93     
        187        ECHO                                                     $93
        188      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.37 ms | 1032 KiB | 26 Q