3v4l.org

run code in 300+ PHP versions simultaneously
<?php // a single colon indicates the option takes a value // a double colon indicates the value may be omitted $shortopts = "hf:v::d"; // GNU-style long options are not required $longopts = ["help", "version"]; $opts = getopt($shortopts, $longopts); // options without values are assigned a value of boolean false // you must check their existence, not their truthiness if (isset($opts["h"]) || isset($opts["help"])) { fprintf(STDERR, "Here is some help!\n"); exit; } // long options are called with two hyphens: "--version" if (isset($opts["version"])) { fprintf(STDERR, "%s Version 223.45" . PHP_EOL, $argv[0]); exit; } // options with values can be called like "-f foo", "-ffoo", or "-f=foo" $file = ""; if (isset($opts["f"])) { $file = $opts["f"]; } if (empty($file)) { fprintf(STDERR, "We wanted a file!" . PHP_EOL); exit(1); } fprintf(STDOUT, "File is %s" . PHP_EOL, $file); // options with optional values must be called like "-v5" or "-v=5" $verbosity = 0; if (isset($opts["v"])) { $verbosity = ($opts["v"] === false) ? 1 : (int)$opts["v"]; } fprintf(STDOUT, "Verbosity is %d" . PHP_EOL, $verbosity); // options called multiple times are passed as an array $debug = 0; if (isset($opts["d"])) { $debug = is_array($opts["d"]) ? count($opts["d"]) : 1; } fprintf(STDOUT, "Debug is %d" . PHP_EOL, $debug); // there is no automated w
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 17
Branch analysis from position: 11
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 27
Branch analysis from position: 19
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 32
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 40
Branch analysis from position: 34
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 49, Position 2 = 58
Branch analysis from position: 49
2 jumps found. (Code = 43) Position 1 = 52, Position 2 = 54
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
2 jumps found. (Code = 43) Position 1 = 67, Position 2 = 76
Branch analysis from position: 67
2 jumps found. (Code = 43) Position 1 = 70, Position 2 = 74
Branch analysis from position: 70
1 jumps found. (Code = 42) Position 1 = 75
Branch analysis from position: 75
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 74
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 76
Branch analysis from position: 54
2 jumps found. (Code = 43) Position 1 = 67, Position 2 = 76
Branch analysis from position: 67
Branch analysis from position: 76
Branch analysis from position: 58
Branch analysis from position: 32
Branch analysis from position: 10
filename:       /in/Vq0H2
function name:  (null)
number of ops:  83
compiled vars:  !0 = $longopts, !1 = $opts, !2 = $shortopts, !3 = $argv, !4 = $file, !5 = $verbosity, !6 = $debug
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   ASSIGN                                                   !0, <array>
    6     1        INIT_FCALL                                               'getopt'
          2        SEND_VAR                                                 !2
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $8      
          5        ASSIGN                                                   !1, $8
    8     6        ISSET_ISEMPTY_DIM_OBJ                         0  ~10     !1, 'h'
          7      > JMPNZ_EX                                         ~10     ~10, ->10
          8    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~11     !1, 'help'
          9        BOOL                                             ~10     ~11
         10    > > JMPZ                                                     ~10, ->17
    9    11    >   INIT_FCALL                                               'fprintf'
         12        FETCH_CONSTANT                                   ~12     'STDERR'
         13        SEND_VAL                                                 ~12
         14        SEND_VAL                                                 'Here+is+some+help%21%0A'
         15        DO_ICALL                                                 
   10    16      > EXIT                                                     
   12    17    >   ISSET_ISEMPTY_DIM_OBJ                         0          !1, 'version'
         18      > JMPZ                                                     ~14, ->27
   13    19    >   INIT_FCALL                                               'fprintf'
         20        FETCH_CONSTANT                                   ~15     'STDERR'
         21        SEND_VAL                                                 ~15
         22        SEND_VAL                                                 '%25s+Version+223.45%0A'
         23        FETCH_DIM_R                                      ~16     !3, 0
         24        SEND_VAL                                                 ~16
         25        DO_ICALL                                                 
         26      > EXIT                                                     
   16    27    >   ASSIGN                                                   !4, ''
   17    28        ISSET_ISEMPTY_DIM_OBJ                         0          !1, 'f'
         29      > JMPZ                                                     ~19, ->32
   18    30    >   FETCH_DIM_R                                      ~20     !1, 'f'
         31        ASSIGN                                                   !4, ~20
   19    32    >   ISSET_ISEMPTY_CV                                         !4
         33      > JMPZ                                                     ~22, ->40
   20    34    >   INIT_FCALL                                               'fprintf'
         35        FETCH_CONSTANT                                   ~23     'STDERR'
         36        SEND_VAL                                                 ~23
         37        SEND_VAL                                                 'We+wanted+a+file%21%0A'
         38        DO_ICALL                                                 
         39      > EXIT                                                     1
   22    40    >   INIT_FCALL                                               'fprintf'
         41        FETCH_CONSTANT                                   ~25     'STDOUT'
         42        SEND_VAL                                                 ~25
         43        SEND_VAL                                                 'File+is+%25s%0A'
         44        SEND_VAR                                                 !4
         45        DO_ICALL                                                 
   24    46        ASSIGN                                                   !5, 0
   25    47        ISSET_ISEMPTY_DIM_OBJ                         0          !1, 'v'
         48      > JMPZ                                                     ~28, ->58
   26    49    >   FETCH_DIM_R                                      ~29     !1, 'v'
         50        TYPE_CHECK                                    4          ~29
         51      > JMPZ                                                     ~30, ->54
         52    >   QM_ASSIGN                                        ~31     1
         53      > JMP                                                      ->57
         54    >   FETCH_DIM_R                                      ~32     !1, 'v'
         55        CAST                                          4  ~33     ~32
         56        QM_ASSIGN                                        ~31     ~33
         57    >   ASSIGN                                                   !5, ~31
   27    58    >   INIT_FCALL                                               'fprintf'
         59        FETCH_CONSTANT                                   ~35     'STDOUT'
         60        SEND_VAL                                                 ~35
         61        SEND_VAL                                                 'Verbosity+is+%25d%0A'
         62        SEND_VAR                                                 !5
         63        DO_ICALL                                                 
   29    64        ASSIGN                                                   !6, 0
   30    65        ISSET_ISEMPTY_DIM_OBJ                         0          !1, 'd'
         66      > JMPZ                                                     ~38, ->76
   31    67    >   FETCH_DIM_R                                      ~39     !1, 'd'
         68        TYPE_CHECK                                  128          ~39
         69      > JMPZ                                                     ~40, ->74
         70    >   FETCH_DIM_R                                      ~41     !1, 'd'
         71        COUNT                                            ~42     ~41
         72        QM_ASSIGN                                        ~43     ~42
         73      > JMP                                                      ->75
         74    >   QM_ASSIGN                                        ~43     1
         75    >   ASSIGN                                                   !6, ~43
   32    76    >   INIT_FCALL                                               'fprintf'
         77        FETCH_CONSTANT                                   ~45     'STDOUT'
         78        SEND_VAL                                                 ~45
         79        SEND_VAL                                                 'Debug+is+%25d%0A'
         80        SEND_VAR                                                 !6
         81        DO_ICALL                                                 
   33    82      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
182.88 ms | 1404 KiB | 17 Q