3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isJson($string) { $decoded = json_decode($string); 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/UCpb0
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   INIT_FCALL                                               'isjson'
          1        SEND_VAL                                                 123
          2        DO_FCALL                                      0  $0      
          3      > JMPZ                                                     $0, ->6
    9     4    >   ECHO                                                     'valid+JSON'
    8     5      > JMP                                                      ->7
   11     6    >   ECHO                                                     'not+valid+JSON'
   12     7    > > RETURN                                                   1

Function isjson:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UCpb0
function name:  isJson
number of ops:  10
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        INIT_FCALL                                               'json_last_error'
          6        DO_ICALL                                         $4      
          7        IS_EQUAL                                         ~5      $4, 0
          8      > RETURN                                                   ~5
    6     9*     > RETURN                                                   null

End of function isjson

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.43 ms | 1439 KiB | 16 Q