3v4l.org

run code in 500+ 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:  32
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        FRAMELESS_ICALL_3                str_replace         ~4      '%60', '%22'
         14        OP_DATA                                                      !0
         15        SEND_VAL                                                     ~4
         16        SEND_VAL                                                     <true>
         17        DO_ICALL                                             $5      
         18        SEND_VAR                                                     $5
         19        DO_ICALL                                                     
   11    20        ECHO                                                         '%0A'
   12    21        ECHO                                                         'With+esceped+str_replace%28%29%0A'
   13    22        INIT_FCALL                                                   'var_dump'
         23        INIT_FCALL                                                   'json_decode'
         24        FRAMELESS_ICALL_3                str_replace         ~7      '%60', '%5C%22'
         25        OP_DATA                                                      !0
         26        SEND_VAL                                                     ~7
         27        SEND_VAL                                                     <true>
         28        DO_ICALL                                             $8      
         29        SEND_VAR                                                     $8
         30        DO_ICALL                                                     
         31      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
152.48 ms | 1920 KiB | 15 Q