3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isJson($string) { if(is_string($string)) { json_decode($string); return (json_last_error() == JSON_ERROR_NONE); } return false; } $a=['arraiii'=>['dentro'=>234]]; $b=json_encode($a); var_dump(isJson($a));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lKBn8
function name:  (null)
number of ops:  12
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   ASSIGN                                                   !0, <array>
   16     1        INIT_FCALL                                               'json_encode'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !1, $3
   18     5        INIT_FCALL                                               'var_dump'
          6        INIT_FCALL                                               'isjson'
          7        SEND_VAR                                                 !0
          8        DO_FCALL                                      0  $5      
          9        SEND_VAR                                                 $5
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

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

End of function isjson

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.96 ms | 1389 KiB | 22 Q