3v4l.org

run code in 300+ PHP versions simultaneously
<?php $passes = ["fo\"obar", "foobar\"", "foobar\\\\\"", "foo\\\"\"bar"]; $expect = '{"foo":{"password":"****"}}'; foreach ($passes as $pass) { $json = json_encode(["foo"=>["password"=>$pass]]); echo $expect; echo preg_replace('{("password"\s*:\s*)"(?:[^"\\\\]|(?:\\\\.))*"}', '$1"****"', $json); if ($expect !== preg_replace('{("password"\s*:\s*)"(?:[^"\\\\]|(?:\\\\.))*"}', '$1"****"', $json)) { echo "Password $pass is out of this league!"; exit(1); } } echo "Filter test ok!";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 30
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 30
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 29
Branch analysis from position: 24
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/M5UD2
function name:  (null)
number of ops:  33
compiled vars:  !0 = $passes, !1 = $expect, !2 = $pass, !3 = $json
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, '%7B%22foo%22%3A%7B%22password%22%3A%22%2A%2A%2A%2A%22%7D%7D'
    5     2      > FE_RESET_R                                       $6      !0, ->30
          3    > > FE_FETCH_R                                               $6, !2, ->30
    6     4    >   INIT_FCALL                                               'json_encode'
          5        INIT_ARRAY                                       ~7      !2, 'password'
          6        INIT_ARRAY                                       ~8      ~7, 'foo'
          7        SEND_VAL                                                 ~8
          8        DO_ICALL                                         $9      
          9        ASSIGN                                                   !3, $9
    7    10        ECHO                                                     !1
    8    11        INIT_FCALL                                               'preg_replace'
         12        SEND_VAL                                                 '%7B%28%22password%22%5Cs%2A%3A%5Cs%2A%29%22%28%3F%3A%5B%5E%22%5C%5C%5D%7C%28%3F%3A%5C%5C.%29%29%2A%22%7D'
         13        SEND_VAL                                                 '%241%22%2A%2A%2A%2A%22'
         14        SEND_VAR                                                 !3
         15        DO_ICALL                                         $11     
         16        ECHO                                                     $11
    9    17        INIT_FCALL                                               'preg_replace'
         18        SEND_VAL                                                 '%7B%28%22password%22%5Cs%2A%3A%5Cs%2A%29%22%28%3F%3A%5B%5E%22%5C%5C%5D%7C%28%3F%3A%5C%5C.%29%29%2A%22%7D'
         19        SEND_VAL                                                 '%241%22%2A%2A%2A%2A%22'
         20        SEND_VAR                                                 !3
         21        DO_ICALL                                         $12     
         22        IS_NOT_IDENTICAL                                         !1, $12
         23      > JMPZ                                                     ~13, ->29
   10    24    >   ROPE_INIT                                     3  ~15     'Password+'
         25        ROPE_ADD                                      1  ~15     ~15, !2
         26        ROPE_END                                      2  ~14     ~15, '+is+out+of+this+league%21'
         27        ECHO                                                     ~14
   11    28      > EXIT                                                     1
    5    29    > > JMP                                                      ->3
         30    >   FE_FREE                                                  $6
   14    31        ECHO                                                     'Filter+test+ok%21'
         32      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.74 ms | 1396 KiB | 17 Q