3v4l.org

run code in 300+ 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        ZEND_CALLABLE_CONVERT                            ~7      
         11        SEND_VAL                                                 ~7
         12        DO_ICALL                                                 
   27    13        INIT_FCALL                                               'var_dump'
         14        INIT_FCALL                                               'json_validate'
         15        ZEND_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 = 41
Branch analysis from position: 33
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
Branch analysis from position: 17
filename:       /in/6sLa4
function name:  {closure}
number of ops:  52
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, ->41
   16    33    >   NEW                                              $15     'ValueError'
         34        INIT_FCALL                                               'sprintf'
         35        SEND_VAL                                                 'json_validate%28%29%3A+Argument+%232+%28%24depth%29+must+be+less+than+%25d'
         36        SEND_VAR                                                 !3
         37        DO_ICALL                                         $16     
         38        SEND_VAR_NO_REF_EX                                       $16
         39        DO_FCALL                                      0          
         40      > THROW                                         0          $15
   18    41    >   INIT_FCALL                                               'json_decode'
         42        SEND_VAR                                                 !0
         43        SEND_VAL                                                 <true>
         44        SEND_VAR                                                 !1
         45        SEND_VAR                                                 !2
         46        DO_ICALL                                                 
   19    47        INIT_FCALL                                               'json_last_error'
         48        DO_ICALL                                         $19     
         49        IS_IDENTICAL                                     ~20     $19, 0
         50      > RETURN                                                   ~20
   20    51*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.84 ms | 1024 KiB | 19 Q