3v4l.org

run code in 300+ PHP versions simultaneously
<?php $test = [ 'HTTP_REFERER' => 'http_referer' ]; function ternary($test) { return (!empty($test['HTTP_REFERER']) ? $test['HTTP_REFERER'] : (!empty($test['HTTP_ORIGIN']) ? $test['HTTP_ORIGIN'] : (!empty($test['ORIGIN']) ? $test['ORIGIN'] : "Unknown Origin"))); } function verbose($test) { if (!empty($test['HTTP_REFERER'])) { return $test['HTTP_REFERER']; } if (!empty($test['HTTP_ORIGIN'])) { return $test['HTTP_ORIGIN']; } if (!empty($test['ORIGIN'])) { return $test['ORIGIN']; } return 'Unknown Origin'; } echo ternary($test); echo \PHP_EOL; echo verbose($test); echo \PHP_EOL . '---' . \PHP_EOL; $test = [ 'HTTP_ORIGIN' => 'http_origin' ]; echo ternary($test); echo \PHP_EOL; echo verbose($test); echo \PHP_EOL . '---' . \PHP_EOL; $test = [ 'ORIGIN' => 'origin' ]; echo ternary($test); echo \PHP_EOL; echo verbose($test);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pKP1C
function name:  (null)
number of ops:  33
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   26     1        INIT_FCALL                                               'ternary'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $2      
          4        ECHO                                                     $2
   27     5        ECHO                                                     '%0A'
   28     6        INIT_FCALL                                               'verbose'
          7        SEND_VAR                                                 !0
          8        DO_FCALL                                      0  $3      
          9        ECHO                                                     $3
   30    10        ECHO                                                     '%0A---%0A'
   32    11        ASSIGN                                                   !0, <array>
   36    12        INIT_FCALL                                               'ternary'
         13        SEND_VAR                                                 !0
         14        DO_FCALL                                      0  $5      
         15        ECHO                                                     $5
   37    16        ECHO                                                     '%0A'
   38    17        INIT_FCALL                                               'verbose'
         18        SEND_VAR                                                 !0
         19        DO_FCALL                                      0  $6      
         20        ECHO                                                     $6
   40    21        ECHO                                                     '%0A---%0A'
   42    22        ASSIGN                                                   !0, <array>
   46    23        INIT_FCALL                                               'ternary'
         24        SEND_VAR                                                 !0
         25        DO_FCALL                                      0  $8      
         26        ECHO                                                     $8
   47    27        ECHO                                                     '%0A'
   48    28        INIT_FCALL                                               'verbose'
         29        SEND_VAR                                                 !0
         30        DO_FCALL                                      0  $9      
         31        ECHO                                                     $9
         32      > RETURN                                                   1

Function ternary:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
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 = 20
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pKP1C
function name:  ternary
number of ops:  24
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        ISSET_ISEMPTY_DIM_OBJ                         1  ~1      !0, 'HTTP_REFERER'
          2        BOOL_NOT                                         ~2      ~1
          3      > JMPZ                                                     ~2, ->7
    8     4    >   FETCH_DIM_R                                      ~3      !0, 'HTTP_REFERER'
          5        QM_ASSIGN                                        ~4      ~3
          6      > JMP                                                      ->22
          7    >   ISSET_ISEMPTY_DIM_OBJ                         1  ~5      !0, 'HTTP_ORIGIN'
          8        BOOL_NOT                                         ~6      ~5
          9      > JMPZ                                                     ~6, ->13
    9    10    >   FETCH_DIM_R                                      ~7      !0, 'HTTP_ORIGIN'
         11        QM_ASSIGN                                        ~8      ~7
         12      > JMP                                                      ->21
         13    >   ISSET_ISEMPTY_DIM_OBJ                         1  ~9      !0, 'ORIGIN'
         14        BOOL_NOT                                         ~10     ~9
         15      > JMPZ                                                     ~10, ->19
   10    16    >   FETCH_DIM_R                                      ~11     !0, 'ORIGIN'
         17        QM_ASSIGN                                        ~12     ~11
         18      > JMP                                                      ->20
         19    >   QM_ASSIGN                                        ~12     'Unknown+Origin'
         20    >   QM_ASSIGN                                        ~8      ~12
         21    >   QM_ASSIGN                                        ~4      ~8
         22    > > RETURN                                                   ~4
   11    23*     > RETURN                                                   null

End of function ternary

Function verbose:
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 = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pKP1C
function name:  verbose
number of ops:  18
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        ISSET_ISEMPTY_DIM_OBJ                         1  ~1      !0, 'HTTP_REFERER'
          2        BOOL_NOT                                         ~2      ~1
          3      > JMPZ                                                     ~2, ->6
   15     4    >   FETCH_DIM_R                                      ~3      !0, 'HTTP_REFERER'
          5      > RETURN                                                   ~3
   17     6    >   ISSET_ISEMPTY_DIM_OBJ                         1  ~4      !0, 'HTTP_ORIGIN'
          7        BOOL_NOT                                         ~5      ~4
          8      > JMPZ                                                     ~5, ->11
   18     9    >   FETCH_DIM_R                                      ~6      !0, 'HTTP_ORIGIN'
         10      > RETURN                                                   ~6
   20    11    >   ISSET_ISEMPTY_DIM_OBJ                         1  ~7      !0, 'ORIGIN'
         12        BOOL_NOT                                         ~8      ~7
         13      > JMPZ                                                     ~8, ->16
   21    14    >   FETCH_DIM_R                                      ~9      !0, 'ORIGIN'
         15      > RETURN                                                   ~9
   23    16    > > RETURN                                                   'Unknown+Origin'
   24    17*     > RETURN                                                   null

End of function verbose

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.68 ms | 1020 KiB | 19 Q