3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isJson($string) { $decoded = json_decode($string); if ( !is_object($decoded) && !is_array($decoded) ) { return false; } return (json_last_error() == JSON_ERROR_NONE); } if ( isJson(123) ) { echo "valid JSON"; } else { echo "not valid JSON"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hhHqs
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   INIT_FCALL                                               'isjson'
          1        SEND_VAL                                                 123
          2        DO_FCALL                                      0  $0      
          3      > JMPZ                                                     $0, ->6
   12     4    >   ECHO                                                     'valid+JSON'
   11     5      > JMP                                                      ->7
   14     6    >   ECHO                                                     'not+valid+JSON'
   15     7    > > RETURN                                                   1

Function isjson:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/hhHqs
function name:  isJson
number of ops:  18
compiled vars:  !0 = $string, !1 = $decoded
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !1, $2
    5     5        TYPE_CHECK                                  256  ~4      !1
          6        BOOL_NOT                                         ~5      ~4
          7      > JMPZ_EX                                          ~5      ~5, ->11
          8    >   TYPE_CHECK                                  128  ~6      !1
          9        BOOL_NOT                                         ~7      ~6
         10        BOOL                                             ~5      ~7
         11    > > JMPZ                                                     ~5, ->13
    6    12    > > RETURN                                                   <false>
    8    13    >   INIT_FCALL                                               'json_last_error'
         14        DO_ICALL                                         $8      
         15        IS_EQUAL                                         ~9      $8, 0
         16      > RETURN                                                   ~9
    9    17*     > RETURN                                                   null

End of function isjson

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.01 ms | 1441 KiB | 16 Q