3v4l.org

run code in 500+ PHP versions simultaneously
<?php $fixtures = [ // Not valid 'foo', '{foo: bar}', "'{'foo': 'bar'}", '{...}', // Valid '"foo"', '1', '{"foo": "bar"}', ]; foreach ($fixtures as $string) { if (json_validate($string)) { echo sprintf('YES, >%s< is a valid JSON string', $string).PHP_EOL; echo 'decoded: '. var_export(json_decode($string), true).PHP_EOL; } else { echo sprintf('NO, >%s< is NOT a valid JSON string: %s', $string, json_last_error_msg()). PHP_EOL; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 32
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 32
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 23
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/EIUPB
function name:  (null)
number of ops:  34
compiled vars:  !0 = $fixtures, !1 = $string
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   16     1      > FE_RESET_R                                           $3      !0, ->32
          2    > > FE_FETCH_R                                                   $3, !1, ->32
   17     3    >   INIT_FCALL                                                   'json_validate'
          4        SEND_VAR                                                     !1
          5        DO_ICALL                                             $4      
          6      > JMPZ                                                         $4, ->23
   18     7    >   ROPE_INIT                                         3  ~6      'YES%2C+%3E'
          8        ROPE_ADD                                          1  ~6      ~6, !1
          9        ROPE_END                                          2  ~5      ~6, '%3C+is+a+valid+JSON+string'
         10        CONCAT                                               ~8      ~5, '%0A'
         11        ECHO                                                         ~8
   19    12        INIT_FCALL                                                   'var_export'
         13        INIT_FCALL                                                   'json_decode'
         14        SEND_VAR                                                     !1
         15        DO_ICALL                                             $9      
         16        SEND_VAR                                                     $9
         17        SEND_VAL                                                     <true>
         18        DO_ICALL                                             $10     
         19        CONCAT                                               ~11     'decoded%3A+', $10
         20        CONCAT                                               ~12     ~11, '%0A'
         21        ECHO                                                         ~12
   17    22      > JMP                                                          ->31
   21    23    >   INIT_FCALL                                                   'json_last_error_msg'
         24        DO_ICALL                                             $13     
         25        ROPE_INIT                                         4  ~15     'NO%2C+%3E'
         26        ROPE_ADD                                          1  ~15     ~15, !1
         27        ROPE_ADD                                          2  ~15     ~15, '%3C+is+NOT+a+valid+JSON+string%3A+'
         28        ROPE_END                                          3  ~14     ~15, $13
         29        CONCAT                                               ~17     ~14, '%0A'
         30        ECHO                                                         ~17
   16    31    > > JMP                                                          ->2
         32    >   FE_FREE                                                      $3
   23    33      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
191.56 ms | 1485 KiB | 17 Q