3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isJson($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/gA6Bf
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                                               'isjson'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $3      
          4        ASSIGN                                                   !1, $3
   19     5        ECHO                                                     !1
   20     6      > RETURN                                                   1

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

End of function isjson

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.51 ms | 1397 KiB | 18 Q