3v4l.org

run code in 300+ PHP versions simultaneously
<?php function ishJson($string) { json_decode($string); //return (json_last_error() == JSON_ERROR_NONE); return json_last_error(); // == JSON_ERROR_NONE); } $str1 = '{ "firstName": "Bidhan" "lastName": "Chatterjee", "age": 40, "email":"bidhan@example.com" }'; //echo json_decode($str1); $x=isJson($str1); echo $x; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/j0GCt
function name:  (null)
number of ops:  7
compiled vars:  !0 = $str1, !1 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   ASSIGN                                                   !0, '%7B%0A%22firstName%22%3A+%22Bidhan%22%0A%22lastName%22%3A+%22Chatterjee%22%2C%0A%22age%22%3A+40%2C%0A%22email%22%3A%22bidhan%40example.com%22%0A%7D'
   18     1        INIT_FCALL_BY_NAME                                       'isJson'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $3      
          4        ASSIGN                                                   !1, $3
   19     5        ECHO                                                     !1
   20     6      > RETURN                                                   1

Function ishjson:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/j0GCt
function name:  ishJson
number of ops:  8
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                                 
    6     4        INIT_FCALL                                               'json_last_error'
          5        DO_ICALL                                         $2      
          6      > RETURN                                                   $2
    9     7*     > RETURN                                                   null

End of function ishjson

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.06 ms | 1395 KiB | 17 Q