3v4l.org

run code in 300+ PHP versions simultaneously
<?php function encode($value, int $flags = 0) { $flags = JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | ($flags & 0) | (defined('JSON_PRESERVE_ZERO_FRACTION') ? JSON_PRESERVE_ZERO_FRACTION : 0); // since PHP 5.6.6 & PECL JSON-C 1.3.7 $json = json_encode($value, $flags); if ($error = json_last_error()) { throw new Exception(json_last_error_msg(), $error); } if (PHP_VERSION_ID < 70100) { $json = str_replace(["\u{2028}", "\u{2029}"], ['\u2028', '\u2029'], $json); } return $json; } echo encode((object)[1 => 2]);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RR3ZS
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_FCALL                                               'encode'
          1        CAST                                          8  ~0      <array>
          2        SEND_VAL                                                 ~0
          3        DO_FCALL                                      0  $1      
          4        ECHO                                                     $1
          5      > RETURN                                                   1

Function encode:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 26
Branch analysis from position: 19
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 33
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 26
Branch analysis from position: 19
Branch analysis from position: 26
filename:       /in/RR3ZS
function name:  encode
number of ops:  35
compiled vars:  !0 = $value, !1 = $flags, !2 = $json, !3 = $error
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      0
    6     2        BW_AND                                           ~4      !1, 0
          3        BW_OR                                            ~5      ~4, 320
    7     4      > JMPZ                                                     <true>, ->7
          5    >   QM_ASSIGN                                        ~6      1024
          6      > JMP                                                      ->8
          7    >   QM_ASSIGN                                        ~6      0
          8    >   BW_OR                                            ~7      ~5, ~6
    5     9        ASSIGN                                                   !1, ~7
    8    10        INIT_FCALL                                               'json_encode'
         11        SEND_VAR                                                 !0
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                         $9      
         14        ASSIGN                                                   !2, $9
    9    15        INIT_FCALL                                               'json_last_error'
         16        DO_ICALL                                         $11     
         17        ASSIGN                                           ~12     !3, $11
         18      > JMPZ                                                     ~12, ->26
   10    19    >   NEW                                              $13     'Exception'
         20        INIT_FCALL                                               'json_last_error_msg'
         21        DO_ICALL                                         $14     
         22        SEND_VAR_NO_REF_EX                                       $14
         23        SEND_VAR_EX                                              !3
         24        DO_FCALL                                      0          
         25      > THROW                                         0          $13
   12    26    > > JMPZ                                                     <false>, ->33
   13    27    >   INIT_FCALL                                               'str_replace'
         28        SEND_VAL                                                 <array>
         29        SEND_VAL                                                 <array>
         30        SEND_VAR                                                 !2
         31        DO_ICALL                                         $16     
         32        ASSIGN                                                   !2, $16
   15    33    > > RETURN                                                   !2
   16    34*     > RETURN                                                   null

End of function encode

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
129.23 ms | 1407 KiB | 22 Q