3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '{"foo": "lorem `bar` ipsum"}'; echo 'Without str_replace()' . PHP_EOL; var_dump(json_decode($json, true)); echo PHP_EOL; echo 'With your current str_replace()' . PHP_EOL; var_dump(json_decode(str_replace('`', '"', $json), true)); echo PHP_EOL; echo 'With esceped str_replace()' . PHP_EOL; var_dump(json_decode(str_replace('`', '\"', $json), true));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bBIBK
function name:  (null)
number of ops:  38
compiled vars:  !0 = $json
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%7B%22foo%22%3A+%22lorem+%60bar%60+ipsum%22%7D'
    4     1        ECHO                                                     'Without+str_replace%28%29%0A'
    5     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'json_decode'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 <true>
          6        DO_ICALL                                         $2      
          7        SEND_VAR                                                 $2
          8        DO_ICALL                                                 
    7     9        ECHO                                                     '%0A'
    8    10        ECHO                                                     'With+your+current+str_replace%28%29%0A'
    9    11        INIT_FCALL                                               'var_dump'
         12        INIT_FCALL                                               'json_decode'
         13        INIT_FCALL                                               'str_replace'
         14        SEND_VAL                                                 '%60'
         15        SEND_VAL                                                 '%22'
         16        SEND_VAR                                                 !0
         17        DO_ICALL                                         $4      
         18        SEND_VAR                                                 $4
         19        SEND_VAL                                                 <true>
         20        DO_ICALL                                         $5      
         21        SEND_VAR                                                 $5
         22        DO_ICALL                                                 
   11    23        ECHO                                                     '%0A'
   12    24        ECHO                                                     'With+esceped+str_replace%28%29%0A'
   13    25        INIT_FCALL                                               'var_dump'
         26        INIT_FCALL                                               'json_decode'
         27        INIT_FCALL                                               'str_replace'
         28        SEND_VAL                                                 '%60'
         29        SEND_VAL                                                 '%5C%22'
         30        SEND_VAR                                                 !0
         31        DO_ICALL                                         $7      
         32        SEND_VAR                                                 $7
         33        SEND_VAL                                                 <true>
         34        DO_ICALL                                         $8      
         35        SEND_VAR                                                 $8
         36        DO_ICALL                                                 
         37      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.7 ms | 1013 KiB | 16 Q