3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @param int $num1 * @param ?int $num2 If null or omitted, it will get the value 1 * * @return int */ function add($num1, $num2 = null) { // If the default value is null, set it to the default $num2 = $num2 ?? 1; print_r($num1, $num2); return $num1 + $num2; } $bool = true; echo add(5, $bool ? 5 : null) . PHP_EOL; $bool = false; echo add(5, $bool ? 5 : null) . PHP_EOL;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
Branch analysis from position: 17
filename:       /in/OAQrk
function name:  (null)
number of ops:  23
compiled vars:  !0 = $bool
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   ASSIGN                                                   !0, <true>
   20     1        INIT_FCALL                                               'add'
          2        SEND_VAL                                                 5
          3      > JMPZ                                                     !0, ->6
          4    >   QM_ASSIGN                                        ~2      5
          5      > JMP                                                      ->7
          6    >   QM_ASSIGN                                        ~2      null
          7    >   SEND_VAL                                                 ~2
          8        DO_FCALL                                      0  $3      
          9        CONCAT                                           ~4      $3, '%0A'
         10        ECHO                                                     ~4
   22    11        ASSIGN                                                   !0, <false>
   24    12        INIT_FCALL                                               'add'
         13        SEND_VAL                                                 5
         14      > JMPZ                                                     !0, ->17
         15    >   QM_ASSIGN                                        ~6      5
         16      > JMP                                                      ->18
         17    >   QM_ASSIGN                                        ~6      null
         18    >   SEND_VAL                                                 ~6
         19        DO_FCALL                                      0  $7      
         20        CONCAT                                           ~8      $7, '%0A'
         21        ECHO                                                     ~8
   25    22      > RETURN                                                   1

Function add:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OAQrk
function name:  add
number of ops:  12
compiled vars:  !0 = $num1, !1 = $num2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   11     2        COALESCE                                         ~2      !1
          3        QM_ASSIGN                                        ~2      1
          4        ASSIGN                                                   !1, ~2
   13     5        INIT_FCALL                                               'print_r'
          6        SEND_VAR                                                 !0
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                                 
   15     9        ADD                                              ~5      !0, !1
         10      > RETURN                                                   ~5
   16    11*     > RETURN                                                   null

End of function add

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.03 ms | 1005 KiB | 16 Q