3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isJson($string) { var_dump(json_decode($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); $c='{hg}'; var_dump(isJson($b));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3M5Be
function name:  (null)
number of ops:  13
compiled vars:  !0 = $a, !1 = $b, !2 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   ASSIGN                                                   !0, <array>
   20     1        INIT_FCALL                                               'json_encode'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $4      
          4        ASSIGN                                                   !1, $4
   21     5        ASSIGN                                                   !2, '%7Bhg%7D'
   23     6        INIT_FCALL                                               'var_dump'
          7        INIT_FCALL                                               'isjson'
          8        SEND_VAR                                                 !1
          9        DO_FCALL                                      0  $7      
         10        SEND_VAR                                                 $7
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

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

End of function isjson

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.8 ms | 1399 KiB | 22 Q