3v4l.org

run code in 500+ PHP versions simultaneously
<?php $contents = <<<EOL console.log('hello'); //# sourceMappingURL= EOL; $backtrack_limit = (int) ini_get('pcre.backtrack_limit'); // Actual limit seems to be this value divided by 2. $backtrack_limit = ($backtrack_limit / 2) - 1; $contents .= str_repeat('x', $backtrack_limit); // Add an empty space after the sourcemap, followed by other code. $contents .= <<<EOL // I appear after the sourcemap. var newcode = 123; EOL; $results = [ 'orig' => preg_replace('/\/\/(#|@)\s(sourceURL|sourceMappingURL)=\s*(\S*?)\s*$/m', '', $contents), 'proposed' => preg_replace('/\/\/(#|@)\s(sourceURL|sourceMappingURL)=\s*[^$\s]*\s*$/m', '', $contents), 'alt1' => preg_replace('/\/\/(#|@)\s(sourceURL|sourceMappingURL)=.*\s*$/m', '', $contents), 'alt2' => preg_replace('/\/\/(#|@)\s(sourceURL|sourceMappingURL)=\s*[^$\s]*/m', '', $contents), // Most efficient so far based off https://regex101.com - (https://stackoverflow.com/a/36629670). 'alt3' => preg_replace('~//[#@]\s(source(?:Mapping)?URL)=\s*(\S+)~', '', $contents), ]; foreach ($results as $key => $result) { echo "------------------------------------------\n"; echo "Results for '$key':\n"; var_dump($result); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 32, Position 2 = 43
Branch analysis from position: 32
2 jumps found. (Code = 78) Position 1 = 33, Position 2 = 43
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
filename:       /in/JagL4
function name:  (null)
number of ops:  45
compiled vars:  !0 = $contents, !1 = $backtrack_limit, !2 = $results, !3 = $result, !4 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, 'console.log%28%27hello%27%29%3B%0A%2F%2F%23+sourceMappingURL%3D'
    8     1        INIT_FCALL                                                   'ini_get'
          2        SEND_VAL                                                     'pcre.backtrack_limit'
          3        DO_ICALL                                             $6      
          4        CAST                                              4  ~7      $6
          5        ASSIGN                                                       !1, ~7
   10     6        DIV                                                  ~9      !1, 2
          7        SUB                                                  ~10     ~9, 1
          8        ASSIGN                                                       !1, ~10
   12     9        INIT_FCALL                                                   'str_repeat'
         10        SEND_VAL                                                     'x'
         11        SEND_VAR                                                     !1
         12        DO_ICALL                                             $12     
         13        ASSIGN_OP                                         8          !0, $12
   15    14        ASSIGN_OP                                         8          !0, '+%2F%2F+I+appear+after+the+sourcemap.%0Avar+newcode+%3D+123%3B'
   20    15        FRAMELESS_ICALL_3                preg_replace        ~15     '%2F%5C%2F%5C%2F%28%23%7C%40%29%5Cs%28sourceURL%7CsourceMappingURL%29%3D%5Cs%2A%28%5CS%2A%3F%29%5Cs%2A%24%2Fm', ''
         16        OP_DATA                                                      !0
         17        INIT_ARRAY                                           ~16     ~15, 'orig'
   21    18        FRAMELESS_ICALL_3                preg_replace        ~17     '%2F%5C%2F%5C%2F%28%23%7C%40%29%5Cs%28sourceURL%7CsourceMappingURL%29%3D%5Cs%2A%5B%5E%24%5Cs%5D%2A%5Cs%2A%24%2Fm', ''
         19        OP_DATA                                                      !0
         20        ADD_ARRAY_ELEMENT                                    ~16     ~17, 'proposed'
   22    21        FRAMELESS_ICALL_3                preg_replace        ~18     '%2F%5C%2F%5C%2F%28%23%7C%40%29%5Cs%28sourceURL%7CsourceMappingURL%29%3D.%2A%5Cs%2A%24%2Fm', ''
         22        OP_DATA                                                      !0
         23        ADD_ARRAY_ELEMENT                                    ~16     ~18, 'alt1'
   23    24        FRAMELESS_ICALL_3                preg_replace        ~19     '%2F%5C%2F%5C%2F%28%23%7C%40%29%5Cs%28sourceURL%7CsourceMappingURL%29%3D%5Cs%2A%5B%5E%24%5Cs%5D%2A%2Fm', ''
         25        OP_DATA                                                      !0
         26        ADD_ARRAY_ELEMENT                                    ~16     ~19, 'alt2'
   25    27        FRAMELESS_ICALL_3                preg_replace        ~20     '%7E%2F%2F%5B%23%40%5D%5Cs%28source%28%3F%3AMapping%29%3FURL%29%3D%5Cs%2A%28%5CS%2B%29%7E', ''
         28        OP_DATA                                                      !0
         29        ADD_ARRAY_ELEMENT                                    ~16     ~20, 'alt3'
   19    30        ASSIGN                                                       !2, ~16
   28    31      > FE_RESET_R                                           $22     !2, ->43
         32    > > FE_FETCH_R                                           ~23     $22, !3, ->43
         33    >   ASSIGN                                                       !4, ~23
   29    34        ECHO                                                         '------------------------------------------%0A'
   30    35        ROPE_INIT                                         3  ~26     'Results+for+%27'
         36        ROPE_ADD                                          1  ~26     ~26, !4
         37        ROPE_END                                          2  ~25     ~26, '%27%3A%0A'
         38        ECHO                                                         ~25
   31    39        INIT_FCALL                                                   'var_dump'
         40        SEND_VAR                                                     !3
         41        DO_ICALL                                                     
   28    42      > JMP                                                          ->32
         43    >   FE_FREE                                                      $22
   32    44      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
217.46 ms | 2160 KiB | 16 Q