3v4l.org

run code in 300+ PHP versions simultaneously
<?php function work($i){ list($v, $u) = split(" ", $i); $u == 'C' || print( $v = $u == 'K' ? $v - 273.15 : ($v - 32)*5/9 ) . " C\n"; $u != "K" && print $v + 273.15 . " K\n"; $u != "F" && print $v * 9/5 + 32 . " F\n"; } function f($i){list($v,$u)=split(" ",$i);$u==C||print($v=$u==K?$v-273.15:($v-32)*5/9)."C\n";$u!=K&&print $v+273.15 ."K\n";$u!=F&&print $v*9/5+32 ."F\n";} @f("23 C"); echo "\n\n"; // Expect 73.4 F 296.15 K @f("86.987 F"); echo "\n\n"; // Expect 303.6983 K 30.5483 C @f("56.99999999 K"); echo "\n\n"; // Expect -216.1500 C -357.0700 F
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CpvG7
function name:  (null)
number of ops:  19
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   BEGIN_SILENCE                                    ~0      
          1        INIT_FCALL                                               'f'
          2        SEND_VAL                                                 '23+C'
          3        DO_FCALL                                      0          
          4        END_SILENCE                                              ~0
          5        ECHO                                                     '%0A%0A'
   13     6        BEGIN_SILENCE                                    ~2      
          7        INIT_FCALL                                               'f'
          8        SEND_VAL                                                 '86.987+F'
          9        DO_FCALL                                      0          
         10        END_SILENCE                                              ~2
         11        ECHO                                                     '%0A%0A'
   14    12        BEGIN_SILENCE                                    ~4      
         13        INIT_FCALL                                               'f'
         14        SEND_VAL                                                 '56.99999999+K'
         15        DO_FCALL                                      0          
         16        END_SILENCE                                              ~4
         17        ECHO                                                     '%0A%0A'
         18      > RETURN                                                   1

Function work:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 12, Position 2 = 25
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 17
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 46) Position 1 = 27, Position 2 = 31
Branch analysis from position: 27
2 jumps found. (Code = 46) Position 1 = 33, Position 2 = 39
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
Branch analysis from position: 31
Branch analysis from position: 17
2 jumps found. (Code = 46) Position 1 = 27, Position 2 = 31
Branch analysis from position: 27
Branch analysis from position: 31
Branch analysis from position: 25
filename:       /in/CpvG7
function name:  work
number of ops:  40
compiled vars:  !0 = $i, !1 = $v, !2 = $u
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL_BY_NAME                                       'split'
          2        SEND_VAL_EX                                              '+'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $3      
          5        FETCH_LIST_R                                     $4      $3, 0
          6        ASSIGN                                                   !1, $4
          7        FETCH_LIST_R                                     $6      $3, 1
          8        ASSIGN                                                   !2, $6
          9        FREE                                                     $3
    5    10        IS_EQUAL                                         ~8      !2, 'C'
         11      > JMPNZ_EX                                         ~8      ~8, ->25
         12    >   IS_EQUAL                                                 !2, 'K'
         13      > JMPZ                                                     ~9, ->17
         14    >   SUB                                              ~10     !1, 273.15
         15        QM_ASSIGN                                        ~11     ~10
         16      > JMP                                                      ->21
         17    >   SUB                                              ~12     !1, 32
         18        MUL                                              ~13     ~12, 5
         19        DIV                                              ~14     ~13, 9
         20        QM_ASSIGN                                        ~11     ~14
         21    >   ASSIGN                                           ~15     !1, ~11
         22        CONCAT                                           ~16     ~15, '+C%0A'
         23        ECHO                                                     ~16
         24        BOOL                                             ~8      1
    6    25    >   IS_NOT_EQUAL                                     ~17     !2, 'K'
         26      > JMPZ_EX                                          ~17     ~17, ->31
         27    >   ADD                                              ~18     !1, 273.15
         28        CONCAT                                           ~19     ~18, '+K%0A'
         29        ECHO                                                     ~19
         30        BOOL                                             ~17     1
    7    31    >   IS_NOT_EQUAL                                     ~20     !2, 'F'
         32      > JMPZ_EX                                          ~20     ~20, ->39
         33    >   MUL                                              ~21     !1, 9
         34        DIV                                              ~22     ~21, 5
         35        ADD                                              ~23     ~22, 32
         36        CONCAT                                           ~24     ~23, '+F%0A'
         37        ECHO                                                     ~24
         38        BOOL                                             ~20     1
    8    39    > > RETURN                                                   null

End of function work

Function f:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 13, Position 2 = 27
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 19
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 46) Position 1 = 30, Position 2 = 34
Branch analysis from position: 30
2 jumps found. (Code = 46) Position 1 = 37, Position 2 = 43
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
Branch analysis from position: 34
Branch analysis from position: 19
2 jumps found. (Code = 46) Position 1 = 30, Position 2 = 34
Branch analysis from position: 30
Branch analysis from position: 34
Branch analysis from position: 27
filename:       /in/CpvG7
function name:  f
number of ops:  44
compiled vars:  !0 = $i, !1 = $v, !2 = $u
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        INIT_FCALL_BY_NAME                                       'split'
          2        SEND_VAL_EX                                              '+'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $3      
          5        FETCH_LIST_R                                     $4      $3, 0
          6        ASSIGN                                                   !1, $4
          7        FETCH_LIST_R                                     $6      $3, 1
          8        ASSIGN                                                   !2, $6
          9        FREE                                                     $3
         10        FETCH_CONSTANT                                   ~8      'C'
         11        IS_EQUAL                                         ~9      !2, ~8
         12      > JMPNZ_EX                                         ~9      ~9, ->27
         13    >   FETCH_CONSTANT                                   ~10     'K'
         14        IS_EQUAL                                                 !2, ~10
         15      > JMPZ                                                     ~11, ->19
         16    >   SUB                                              ~12     !1, 273.15
         17        QM_ASSIGN                                        ~13     ~12
         18      > JMP                                                      ->23
         19    >   SUB                                              ~14     !1, 32
         20        MUL                                              ~15     ~14, 5
         21        DIV                                              ~16     ~15, 9
         22        QM_ASSIGN                                        ~13     ~16
         23    >   ASSIGN                                           ~17     !1, ~13
         24        CONCAT                                           ~18     ~17, 'C%0A'
         25        ECHO                                                     ~18
         26        BOOL                                             ~9      1
         27    >   FETCH_CONSTANT                                   ~19     'K'
         28        IS_NOT_EQUAL                                     ~20     !2, ~19
         29      > JMPZ_EX                                          ~20     ~20, ->34
         30    >   ADD                                              ~21     !1, 273.15
         31        CONCAT                                           ~22     ~21, 'K%0A'
         32        ECHO                                                     ~22
         33        BOOL                                             ~20     1
         34    >   FETCH_CONSTANT                                   ~23     'F'
         35        IS_NOT_EQUAL                                     ~24     !2, ~23
         36      > JMPZ_EX                                          ~24     ~24, ->43
         37    >   MUL                                              ~25     !1, 9
         38        DIV                                              ~26     ~25, 5
         39        ADD                                              ~27     ~26, 32
         40        CONCAT                                           ~28     ~27, 'F%0A'
         41        ECHO                                                     ~28
         42        BOOL                                             ~24     1
         43    > > RETURN                                                   null

End of function f

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.41 ms | 1417 KiB | 16 Q