3v4l.org

run code in 300+ PHP versions simultaneously
<?php $test = [ null, false, 1, 1.5, 'string', ['string in array without keys'], ['key' => 'string in array with keys'], [ 'multi-dim array' => 'string', 'sub-array' => [ 1, 2, 3] ], ]; foreach($test as $l10n) { echo PHP_EOL,'=======================', PHP_EOL; echo PHP_EOL,'Input',PHP_EOL; var_dump($l10n); $copy = $l10n; foreach ( (array) $l10n as $key => $value ) { if ( ! is_scalar( $value ) ) { continue; } $l10n[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); } $encoded1 = json_encode( $l10n ); echo PHP_EOL,'Original output',PHP_EOL; var_dump($encoded1); $l10n = $copy; if ( is_string( $l10n ) ) { $l10n = html_entity_decode( (string) $l10n, ENT_QUOTES, 'UTF-8' ); } else { $l10n = (array) $l10n; foreach ( $l10n as $key => $value ) { if ( ! is_scalar( $value ) ) { continue; } $l10n[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); } } $encoded2 = json_encode( $l10n ); echo PHP_EOL,'Patch Peter output',PHP_EOL; var_dump($encoded2); if ($encoded1 !== $encoded2) { echo "*** BC-break detected in patch!! ***", PHP_EOL; } $l10n = $copy; if ( ! is_array( $l10n ) ) { $l10n = html_entity_decode( (string) $l10n, ENT_QUOTES, 'UTF-8' ); } else { foreach ( $l10n as $key => $value ) { if ( ! is_scalar( $value ) ) { continue; } $l10n[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); } } $encoded3 = json_encode( $l10n ); echo PHP_EOL,'Patch Sergey output',PHP_EOL; var_dump($encoded3); if ($encoded1 !== $encoded3) { echo "*** BC-break detected in patch!! ***", PHP_EOL; } $l10n = $copy; if ( ! is_array( $l10n ) ) { // Throw the _doing_it_wrong_warning. $l10n = (array) $l10n; } foreach ( $l10n as $key => $value ) { if ( ! is_scalar( $value ) ) { continue; } $l10n[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); } $encoded4 = json_encode( $l10n ); echo PHP_EOL,'Patch 1 Juliette output',PHP_EOL; var_dump($encoded4); if ($encoded1 !== $encoded4) { echo "*** BC-break detected in patch!! ***", PHP_EOL; } $l10n = $copy; if ( ! is_array( $l10n ) ) { // Throw the _doing_it_wrong_warning. } if ( is_string( $l10n ) ) { $l10n = html_entity_decode( (string) $l10n, ENT_QUOTES, 'UTF-8' ); } else { foreach ( (array) $l10n as $key => $value ) { if ( ! is_scalar( $value ) ) { continue; } $l10n[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); } } $encoded5 = json_encode( $l10n ); echo PHP_EOL,'Patch 2 Juliette output',PHP_EOL; var_dump($encoded5); if ($encoded1 !== $encoded5) { echo "*** BC-break detected in patch!! ***", PHP_EOL; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 222
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 222
Branch analysis from position: 3
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 32
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 32
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 23
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 54
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 75
Branch analysis from position: 75
2 jumps found. (Code = 43) Position 1 = 87, Position 2 = 89
Branch analysis from position: 87
2 jumps found. (Code = 43) Position 1 = 93, Position 2 = 101
Branch analysis from position: 93
1 jumps found. (Code = 42) Position 1 = 120
Branch analysis from position: 120
2 jumps found. (Code = 43) Position 1 = 132, Position 2 = 134
Branch analysis from position: 132
2 jumps found. (Code = 43) Position 1 = 138, Position 2 = 140
Branch analysis from position: 138
2 jumps found. (Code = 77) Position 1 = 141, Position 2 = 158
Branch analysis from position: 141
2 jumps found. (Code = 78) Position 1 = 142, Position 2 = 158
Branch analysis from position: 142
2 jumps found. (Code = 43) Position 1 = 148, Position 2 = 149
Branch analysis from position: 148
1 jumps found. (Code = 42) Position 1 = 141
Branch analysis from position: 141
Branch analysis from position: 149
1 jumps found. (Code = 42) Position 1 = 141
Branch analysis from position: 141
Branch analysis from position: 158
2 jumps found. (Code = 43) Position 1 = 171, Position 2 = 173
Branch analysis from position: 171
2 jumps found. (Code = 43) Position 1 = 177, Position 2 = 177
Branch analysis from position: 177
2 jumps found. (Code = 43) Position 1 = 179, Position 2 = 187
Branch analysis from position: 179
1 jumps found. (Code = 42) Position 1 = 207
Branch analysis from position: 207
2 jumps found. (Code = 43) Position 1 = 219, Position 2 = 221
Branch analysis from position: 219
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 221
Branch analysis from position: 187
2 jumps found. (Code = 77) Position 1 = 189, Position 2 = 206
Branch analysis from position: 189
2 jumps found. (Code = 78) Position 1 = 190, Position 2 = 206
Branch analysis from position: 190
2 jumps found. (Code = 43) Position 1 = 196, Position 2 = 197
Branch analysis from position: 196
1 jumps found. (Code = 42) Position 1 = 189
Branch analysis from position: 189
Branch analysis from position: 197
1 jumps found. (Code = 42) Position 1 = 189
Branch analysis from position: 189
Branch analysis from position: 206
2 jumps found. (Code = 43) Position 1 = 219, Position 2 = 221
Branch analysis from position: 219
Branch analysis from position: 221
Branch analysis from position: 206
Branch analysis from position: 177
Branch analysis from position: 173
Branch analysis from position: 158
Branch analysis from position: 140
Branch analysis from position: 134
Branch analysis from position: 101
2 jumps found. (Code = 77) Position 1 = 102, Position 2 = 119
Branch analysis from position: 102
2 jumps found. (Code = 78) Position 1 = 103, Position 2 = 119
Branch analysis from position: 103
2 jumps found. (Code = 43) Position 1 = 109, Position 2 = 110
Branch analysis from position: 109
1 jumps found. (Code = 42) Position 1 = 102
Branch analysis from position: 102
Branch analysis from position: 110
1 jumps found. (Code = 42) Position 1 = 102
Branch analysis from position: 102
Branch analysis from position: 119
2 jumps found. (Code = 43) Position 1 = 132, Position 2 = 134
Branch analysis from position: 132
Branch analysis from position: 134
Branch analysis from position: 119
Branch analysis from position: 89
Branch analysis from position: 54
2 jumps found. (Code = 77) Position 1 = 57, Position 2 = 74
Branch analysis from position: 57
2 jumps found. (Code = 78) Position 1 = 58, Position 2 = 74
Branch analysis from position: 58
2 jumps found. (Code = 43) Position 1 = 64, Position 2 = 65
Branch analysis from position: 64
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
Branch analysis from position: 65
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
Branch analysis from position: 74
2 jumps found. (Code = 43) Position 1 = 87, Position 2 = 89
Branch analysis from position: 87
Branch analysis from position: 89
Branch analysis from position: 74
Branch analysis from position: 32
Branch analysis from position: 222
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 222
filename:       /in/ODNk5
function name:  (null)
number of ops:  224
compiled vars:  !0 = $test, !1 = $l10n, !2 = $copy, !3 = $value, !4 = $key, !5 = $encoded1, !6 = $encoded2, !7 = $encoded3, !8 = $encoded4, !9 = $encoded5
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   ASSIGN                                                   !0, <array>
  16     1      > FE_RESET_R                                       $11     !0, ->222
         2    > > FE_FETCH_R                                               $11, !1, ->222
  17     3    >   ECHO                                                     '%0A'
         4        ECHO                                                     '%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D'
         5        ECHO                                                     '%0A'
  18     6        ECHO                                                     '%0A'
         7        ECHO                                                     'Input'
         8        ECHO                                                     '%0A'
  19     9        INIT_FCALL                                               'var_dump'
        10        SEND_VAR                                                 !1
        11        DO_ICALL                                                 
  21    12        ASSIGN                                                   !2, !1
  23    13        MAKE_REF                                         ~14     !1
        14      > FE_RESET_R                                       $15     ~14, ->32
        15    > > FE_FETCH_R                                       ~16     $15, !3, ->32
        16    >   ASSIGN                                                   !4, ~16
  24    17        INIT_FCALL                                               'is_scalar'
        18        SEND_VAR                                                 !3
        19        DO_ICALL                                         $18     
        20        BOOL_XOR                                         ~19     $18
        21      > JMPZ                                                     ~19, ->23
  25    22    > > JMP                                                      ->15
  28    23    >   INIT_FCALL                                               'html_entity_decode'
        24        MAKE_REF                                         ~21     !3
        25        SEND_VAL                                                 ~21
        26        SEND_VAL                                                 3
        27        SEND_VAL                                                 'UTF-8'
        28        DO_ICALL                                         $22     
        29        ASSIGN_DIM                                               !1, !4
        30        OP_DATA                                                  $22
  23    31      > JMP                                                      ->15
        32    >   FE_FREE                                                  $15
  31    33        INIT_FCALL                                               'json_encode'
        34        SEND_VAR                                                 !1
        35        DO_ICALL                                         $23     
        36        ASSIGN                                                   !5, $23
  33    37        ECHO                                                     '%0A'
        38        ECHO                                                     'Original+output'
        39        ECHO                                                     '%0A'
  34    40        INIT_FCALL                                               'var_dump'
        41        SEND_VAR                                                 !5
        42        DO_ICALL                                                 
  36    43        ASSIGN                                                   !1, !2
  38    44        TYPE_CHECK                                   64  ~27     !1
        45      > JMPZ                                                     ~27, ->54
  39    46    >   INIT_FCALL                                               'html_entity_decode'
        47        MAKE_REF                                         ~28     !1
        48        SEND_VAL                                                 ~28
        49        SEND_VAL                                                 3
        50        SEND_VAL                                                 'UTF-8'
        51        DO_ICALL                                         $29     
        52        ASSIGN                                                   !1, $29
        53      > JMP                                                      ->75
  41    54    >   MAKE_REF                                         ~31     !1
        55        ASSIGN                                                   !1, ~31
  42    56      > FE_RESET_R                                       $33     !1, ->74
        57    > > FE_FETCH_R                                       ~34     $33, !3, ->74
        58    >   ASSIGN                                                   !4, ~34
  43    59        INIT_FCALL                                               'is_scalar'
        60        SEND_VAR                                                 !3
        61        DO_ICALL                                         $36     
        62        BOOL_XOR                                         ~37     $36
        63      > JMPZ                                                     ~37, ->65
  44    64    > > JMP                                                      ->57
  47    65    >   INIT_FCALL                                               'html_entity_decode'
        66        MAKE_REF                                         ~39     !3
        67        SEND_VAL                                                 ~39
        68        SEND_VAL                                                 3
        69        SEND_VAL                                                 'UTF-8'
        70        DO_ICALL                                         $40     
        71        ASSIGN_DIM                                               !1, !4
        72        OP_DATA                                                  $40
  42    73      > JMP                                                      ->57
        74    >   FE_FREE                                                  $33
  51    75    >   INIT_FCALL                                               'json_encode'
        76        SEND_VAR                                                 !1
        77        DO_ICALL                                         $41     
        78        ASSIGN                                                   !6, $41
  53    79        ECHO                                                     '%0A'
        80        ECHO                                                     'Patch+Peter+output'
        81        ECHO                                                     '%0A'
  54    82        INIT_FCALL                                               'var_dump'
        83        SEND_VAR                                                 !6
        84        DO_ICALL                                                 
  56    85        IS_EQUAL                                         ~44     !5, !6
        86      > JMPZ                                                     ~44, ->89
  57    87    >   ECHO                                                     '%2A%2A%2A+BC-break+detected+in+patch%21%21+%2A%2A%2A'
        88        ECHO                                                     '%0A'
  60    89    >   ASSIGN                                                   !1, !2
  62    90        TYPE_CHECK                                  128  ~46     !1
        91        BOOL_XOR                                         ~47     ~46
        92      > JMPZ                                                     ~47, ->101
  63    93    >   INIT_FCALL                                               'html_entity_decode'
        94        MAKE_REF                                         ~48     !1
        95        SEND_VAL                                                 ~48
        96        SEND_VAL                                                 3
        97        SEND_VAL                                                 'UTF-8'
        98        DO_ICALL                                         $49     
        99        ASSIGN                                                   !1, $49
       100      > JMP                                                      ->120
  65   101    > > FE_RESET_R                                       $51     !1, ->119
       102    > > FE_FETCH_R                                       ~52     $51, !3, ->119
       103    >   ASSIGN                                                   !4, ~52
  66   104        INIT_FCALL                                               'is_scalar'
       105        SEND_VAR                                                 !3
       106        DO_ICALL                                         $54     
       107        BOOL_XOR                                         ~55     $54
       108      > JMPZ                                                     ~55, ->110
  67   109    > > JMP                                                      ->102
  70   110    >   INIT_FCALL                                               'html_entity_decode'
       111        MAKE_REF                                         ~57     !3
       112        SEND_VAL                                                 ~57
       113        SEND_VAL                                                 3
       114        SEND_VAL                                                 'UTF-8'
       115        DO_ICALL                                         $58     
       116        ASSIGN_DIM                                               !1, !4
       117        OP_DATA                                                  $58
  65   118      > JMP                                                      ->102
       119    >   FE_FREE                                                  $51
  74   120    >   INIT_FCALL                                               'json_encode'
       121        SEND_VAR                                                 !1
       122        DO_ICALL                                         $59     
       123        ASSIGN                                                   !7, $59
  76   124        ECHO                                                     '%0A'
       125        ECHO                                                     'Patch+Sergey+output'
       126        ECHO                                                     '%0A'
  77   127        INIT_FCALL                                               'var_dump'
       128        SEND_VAR                                                 !7
       129        DO_ICALL                                                 
  79   130        IS_EQUAL                                         ~62     !5, !7
       131      > JMPZ                                                     ~62, ->134
  80   132    >   ECHO                                                     '%2A%2A%2A+BC-break+detected+in+patch%21%21+%2A%2A%2A'
       133        ECHO                                                     '%0A'
  83   134    >   ASSIGN                                                   !1, !2
  85   135        TYPE_CHECK                                  128  ~64     !1
       136        BOOL_XOR                                         ~65     ~64
       137      > JMPZ                                                     ~65, ->140
  87   138    >   MAKE_REF                                         ~66     !1
       139        ASSIGN                                                   !1, ~66
  90   140    > > FE_RESET_R                                       $68     !1, ->158
       141    > > FE_FETCH_R                                       ~69     $68, !3, ->158
       142    >   ASSIGN                                                   !4, ~69
  91   143        INIT_FCALL                                               'is_scalar'
       144        SEND_VAR                                                 !3
       145        DO_ICALL                                         $71     
       146        BOOL_XOR                                         ~72     $71
       147      > JMPZ                                                     ~72, ->149
  92   148    > > JMP                                                      ->141
  95   149    >   INIT_FCALL                                               'html_entity_decode'
       150        MAKE_REF                                         ~74     !3
       151        SEND_VAL                                                 ~74
       152        SEND_VAL                                                 3
       153        SEND_VAL                                                 'UTF-8'
       154        DO_ICALL                                         $75     
       155        ASSIGN_DIM                                               !1, !4
       156        OP_DATA                                                  $75
  90   157      > JMP                                                      ->141
       158    >   FE_FREE                                                  $68
  98   159        INIT_FCALL                                               'json_encode'
       160        SEND_VAR                                                 !1
       161        DO_ICALL                                         $76     
       162        ASSIGN                                                   !8, $76
 100   163        ECHO                                                     '%0A'
       164        ECHO                                                     'Patch+1+Juliette+output'
       165        ECHO                                                     '%0A'
 101   166        INIT_FCALL                                               'var_dump'
       167        SEND_VAR                                                 !8
       168        DO_ICALL                                                 
 103   169        IS_EQUAL                                         ~79     !5, !8
       170      > JMPZ                                                     ~79, ->173
 104   171    >   ECHO                                                     '%2A%2A%2A+BC-break+detected+in+patch%21%21+%2A%2A%2A'
       172        ECHO                                                     '%0A'
 107   173    >   ASSIGN                                                   !1, !2
 109   174        TYPE_CHECK                                  128  ~81     !1
       175        BOOL_XOR                                         ~82     ~81
       176      > JMPZ                                                     ~82, ->177
 114   177    >   TYPE_CHECK                                   64  ~83     !1
       178      > JMPZ                                                     ~83, ->187
 115   179    >   INIT_FCALL                                               'html_entity_decode'
       180        MAKE_REF                                         ~84     !1
       181        SEND_VAL                                                 ~84
       182        SEND_VAL                                                 3
       183        SEND_VAL                                                 'UTF-8'
       184        DO_ICALL                                         $85     
       185        ASSIGN                                                   !1, $85
       186      > JMP                                                      ->207
 117   187    >   MAKE_REF                                         ~87     !1
       188      > FE_RESET_R                                       $88     ~87, ->206
       189    > > FE_FETCH_R                                       ~89     $88, !3, ->206
       190    >   ASSIGN                                                   !4, ~89
 118   191        INIT_FCALL                                               'is_scalar'
       192        SEND_VAR                                                 !3
       193        DO_ICALL                                         $91     
       194        BOOL_XOR                                         ~92     $91
       195      > JMPZ                                                     ~92, ->197
 119   196    > > JMP                                                      ->189
 122   197    >   INIT_FCALL                                               'html_entity_decode'
       198        MAKE_REF                                         ~94     !3
       199        SEND_VAL                                                 ~94
       200        SEND_VAL                                                 3
       201        SEND_VAL                                                 'UTF-8'
       202        DO_ICALL                                         $95     
       203        ASSIGN_DIM                                               !1, !4
       204        OP_DATA                                                  $95
 117   205      > JMP                                                      ->189
       206    >   FE_FREE                                                  $88
 126   207    >   INIT_FCALL                                               'json_encode'
       208        SEND_VAR                                                 !1
       209        DO_ICALL                                         $96     
       210        ASSIGN                                                   !9, $96
 128   211        ECHO                                                     '%0A'
       212        ECHO                                                     'Patch+2+Juliette+output'
       213        ECHO                                                     '%0A'
 129   214        INIT_FCALL                                               'var_dump'
       215        SEND_VAR                                                 !9
       216        DO_ICALL                                                 
 131   217        IS_EQUAL                                         ~99     !5, !9
       218      > JMPZ                                                     ~99, ->221
 132   219    >   ECHO                                                     '%2A%2A%2A+BC-break+detected+in+patch%21%21+%2A%2A%2A'
       220        ECHO                                                     '%0A'
  16   221    > > JMP                                                      ->2
       222    >   FE_FREE                                                  $11
 134   223      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
15.1 ms | 483 KiB | 7 Q