3v4l.org

run code in 500+ PHP versions simultaneously
<?php $json = '{"1": "a"}'; $jsonValidate = function (string $json, int $depth = 512, int $flags = 0) { if (function_exists('json_validate')) { return json_validate($json, $depth, $flags); } $maxDepth = 0x7fffffff; if (0 !== $flags && \defined('JSON_INVALID_UTF8_IGNORE') && \JSON_INVALID_UTF8_IGNORE !== $flags) { throw new \ValueError('json_validate(): Argument #3 ($flags) must be a valid flag (allowed flags: JSON_INVALID_UTF8_IGNORE)'); } if ($depth <= 0) { throw new \ValueError('json_validate(): Argument #2 ($depth) must be greater than 0'); } if ($depth > $maxDepth) { throw new \ValueError(sprintf('json_validate(): Argument #2 ($depth) must be less than %d', $maxDepth)); } json_decode($json, true, $depth, $flags); return \JSON_ERROR_NONE === json_last_error(); }; echo (int) $jsonValidate($json); var_dump($jsonValidate(...)); // error when function not exists var_dump(json_validate(...));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6sLa4
function name:  (null)
number of ops:  19
compiled vars:  !0 = $json, !1 = $jsonValidate
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, '%7B%221%22%3A+%22a%22%7D'
    4     1        DECLARE_LAMBDA_FUNCTION                              ~3      [0]
          2        ASSIGN                                                       !1, ~3
   22     3        INIT_DYNAMIC_CALL                                            !1
          4        SEND_VAR_EX                                                  !0
          5        DO_FCALL                                          0  $5      
          6        CAST                                              4  ~6      $5
          7        ECHO                                                         ~6
   24     8        INIT_FCALL                                                   'var_dump'
          9        INIT_DYNAMIC_CALL                                            !1
         10        CALLABLE_CONVERT                                     ~7      
         11        SEND_VAL                                                     ~7
         12        DO_ICALL                                                     
   27    13        INIT_FCALL                                                   'var_dump'
         14        INIT_FCALL                                                   'json_validate'
         15        CALLABLE_CONVERT                                     ~9      
         16        SEND_VAL                                                     ~9
         17        DO_ICALL                                                     
         18      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 13
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 46) Position 1 = 16, Position 2 = 17
Branch analysis from position: 16
2 jumps found. (Code = 46) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 25
Branch analysis from position: 21
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 31
Branch analysis from position: 27
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 40
Branch analysis from position: 33
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
Branch analysis from position: 17
filename:       /in/6sLa4
function name:  {closure:/in/6sLa4:4}
number of ops:  51
compiled vars:  !0 = $json, !1 = $depth, !2 = $flags, !3 = $maxDepth
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    4     0  E >   RECV                                                 !0      
          1        RECV_INIT                                            !1      512
          2        RECV_INIT                                            !2      0
    5     3        INIT_FCALL                                                   'function_exists'
          4        SEND_VAL                                                     'json_validate'
          5        DO_ICALL                                             $4      
          6      > JMPZ                                                         $4, ->13
    6     7    >   INIT_FCALL                                                   'json_validate'
          8        SEND_VAR                                                     !0
          9        SEND_VAR                                                     !1
         10        SEND_VAR                                                     !2
         11        DO_ICALL                                             $5      
         12      > RETURN                                                       $5
    8    13    >   ASSIGN                                                       !3, 2147483647
    9    14        IS_NOT_IDENTICAL                                     ~7      !2, 0
         15      > JMPZ_EX                                              ~7      ~7, ->17
         16    >   BOOL                                                 ~7      <true>
         17    > > JMPZ_EX                                              ~7      ~7, ->20
         18    >   IS_NOT_IDENTICAL                                     ~8      !2, 1048576
         19        BOOL                                                 ~7      ~8
         20    > > JMPZ                                                         ~7, ->25
   10    21    >   NEW                                                  $9      'ValueError'
         22        SEND_VAL_EX                                                  'json_validate%28%29%3A+Argument+%233+%28%24flags%29+must+be+a+valid+flag+%28allowed+flags%3A+JSON_INVALID_UTF8_IGNORE%29'
         23        DO_FCALL                                          0          
         24      > THROW                                             0          $9
   12    25    >   IS_SMALLER_OR_EQUAL                                          !1, 0
         26      > JMPZ                                                         ~11, ->31
   13    27    >   NEW                                                  $12     'ValueError'
         28        SEND_VAL_EX                                                  'json_validate%28%29%3A+Argument+%232+%28%24depth%29+must+be+greater+than+0'
         29        DO_FCALL                                          0          
         30      > THROW                                             0          $12
   15    31    >   IS_SMALLER                                                   !3, !1
         32      > JMPZ                                                         ~14, ->40
   16    33    >   NEW                                                  $15     'ValueError'
         34        NOP                                                          
         35        CAST                                              4  ~16     !3
         36        FAST_CONCAT                                          ~17     'json_validate%28%29%3A+Argument+%232+%28%24depth%29+must+be+less+than+', ~16
         37        SEND_VAL_EX                                                  ~17
         38        DO_FCALL                                          0          
         39      > THROW                                             0          $15
   18    40    >   INIT_FCALL                                                   'json_decode'
         41        SEND_VAR                                                     !0
         42        SEND_VAL                                                     <true>
         43        SEND_VAR                                                     !1
         44        SEND_VAR                                                     !2
         45        DO_ICALL                                                     
   19    46        INIT_FCALL                                                   'json_last_error'
         47        DO_ICALL                                             $20     
         48        IS_IDENTICAL                                         ~21     $20, 0
         49      > RETURN                                                       ~21
   20    50*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
168.21 ms | 1494 KiB | 18 Q