3v4l.org

run code in 300+ PHP versions simultaneously
<?php $corrupted = <<<STRING a:4:{i:0;s:3:"three";i:1;s:5:"five";i:2;s:2:"newline1 newline2";i:3;s:6:"garçon";} STRING; echo $corrupted; echo "\n---\n"; echo "fails to allow newline characers:\n"; var_export(unserialize(preg_replace_callback('!s:(\d+):"(.*?)";!', function($m) { return 's:'.mb_strlen($m[2]).':"'.$m[2].'";'; }, $corrupted))); echo "\n\nfails to appropriately count bytes:\n"; var_export(unserialize(preg_replace_callback('!s:(\d+):"(.*?)";!s', function($m) { return 's:'.mb_strlen($m[2]).':"'.$m[2].'";'; }, $corrupted))); echo"\n---\n"; echo "USE THIS PATTERN WITH THIS REPLACEMENT:\n"; var_export(preg_replace_callback( '/s:\d+:"(.*?)";/s', function ($m) { return "s:" . strlen($m[1]) . ":\"{$m[1]}\";"; }, $corrupted ));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Cf6Nh
function name:  (null)
number of ops:  41
compiled vars:  !0 = $corrupted
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'a%3A4%3A%7Bi%3A0%3Bs%3A3%3A%22three%22%3Bi%3A1%3Bs%3A5%3A%22five%22%3Bi%3A2%3Bs%3A2%3A%22newline1%0Anewline2%22%3Bi%3A3%3Bs%3A6%3A%22gar%C3%A7on%22%3B%7D'
    7     1        ECHO                                                     !0
    8     2        ECHO                                                     '%0A---%0A'
   10     3        ECHO                                                     'fails+to+allow+newline+characers%3A%0A'
   11     4        INIT_FCALL                                               'var_export'
          5        INIT_FCALL                                               'unserialize'
          6        INIT_FCALL                                               'preg_replace_callback'
          7        SEND_VAL                                                 '%21s%3A%28%5Cd%2B%29%3A%22%28.%2A%3F%29%22%3B%21'
          8        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FCf6Nh%3A11%240'
          9        SEND_VAL                                                 ~2
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $3      
         12        SEND_VAR                                                 $3
         13        DO_ICALL                                         $4      
         14        SEND_VAR                                                 $4
         15        DO_ICALL                                                 
   13    16        ECHO                                                     '%0A%0Afails+to+appropriately+count+bytes%3A%0A'
   14    17        INIT_FCALL                                               'var_export'
         18        INIT_FCALL                                               'unserialize'
         19        INIT_FCALL                                               'preg_replace_callback'
         20        SEND_VAL                                                 '%21s%3A%28%5Cd%2B%29%3A%22%28.%2A%3F%29%22%3B%21s'
         21        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FCf6Nh%3A14%241'
         22        SEND_VAL                                                 ~6
         23        SEND_VAR                                                 !0
         24        DO_ICALL                                         $7      
         25        SEND_VAR                                                 $7
         26        DO_ICALL                                         $8      
         27        SEND_VAR                                                 $8
         28        DO_ICALL                                                 
   16    29        ECHO                                                     '%0A---%0A'
   18    30        ECHO                                                     'USE+THIS+PATTERN+WITH+THIS+REPLACEMENT%3A%0A'
   19    31        INIT_FCALL                                               'var_export'
         32        INIT_FCALL                                               'preg_replace_callback'
   20    33        SEND_VAL                                                 '%2Fs%3A%5Cd%2B%3A%22%28.%2A%3F%29%22%3B%2Fs'
   21    34        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FCf6Nh%3A21%242'
   23    35        SEND_VAL                                                 ~10
   24    36        SEND_VAR                                                 !0
         37        DO_ICALL                                         $11     
         38        SEND_VAR                                                 $11
         39        DO_ICALL                                                 
   25    40      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FCf6Nh%3A11%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Cf6Nh
function name:  {closure}
number of ops:  12
compiled vars:  !0 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'mb_strlen'
          2        FETCH_DIM_R                                      ~1      !0, 2
          3        SEND_VAL                                                 ~1
          4        DO_ICALL                                         $2      
          5        CONCAT                                           ~3      's%3A', $2
          6        CONCAT                                           ~4      ~3, '%3A%22'
          7        FETCH_DIM_R                                      ~5      !0, 2
          8        CONCAT                                           ~6      ~4, ~5
          9        CONCAT                                           ~7      ~6, '%22%3B'
         10      > RETURN                                                   ~7
         11*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FCf6Nh%3A11%240

Function %00%7Bclosure%7D%2Fin%2FCf6Nh%3A14%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Cf6Nh
function name:  {closure}
number of ops:  12
compiled vars:  !0 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'mb_strlen'
          2        FETCH_DIM_R                                      ~1      !0, 2
          3        SEND_VAL                                                 ~1
          4        DO_ICALL                                         $2      
          5        CONCAT                                           ~3      's%3A', $2
          6        CONCAT                                           ~4      ~3, '%3A%22'
          7        FETCH_DIM_R                                      ~5      !0, 2
          8        CONCAT                                           ~6      ~4, ~5
          9        CONCAT                                           ~7      ~6, '%22%3B'
         10      > RETURN                                                   ~7
         11*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FCf6Nh%3A14%241

Function %00%7Bclosure%7D%2Fin%2FCf6Nh%3A21%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Cf6Nh
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   22     1        FETCH_DIM_R                                      ~1      !0, 1
          2        STRLEN                                           ~2      ~1
          3        CONCAT                                           ~3      's%3A', ~2
          4        ROPE_INIT                                     3  ~6      '%3A%22'
          5        FETCH_DIM_R                                      ~4      !0, 1
          6        ROPE_ADD                                      1  ~6      ~6, ~4
          7        ROPE_END                                      2  ~5      ~6, '%22%3B'
          8        CONCAT                                           ~8      ~3, ~5
          9      > RETURN                                                   ~8
   23    10*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FCf6Nh%3A21%242

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.16 ms | 1404 KiB | 21 Q