3v4l.org

run code in 300+ PHP versions simultaneously
<?php $fName = "item.txt"; // 1 $fp = fopen($fName, "r") or die("File not found/opened!"); // 2 $lineCount = 0; while ($lineIn = fgets($fp) ) { // 3 print("$lineIn <br/>"); $lineCount++; } print ("line count = $lineCount<br/><br/>"); fclose($fp); $fp = fopen($fName, "r"); // 4 $lineIn = fgets($fp); $id = substr($lineIn, 0, 5); $name = substr($lineIn, 6, 14); $cost = substr($lineIn, 21, 6); $qty = substr($lineIn, 28, 1); print("<pre>"); print("$id\t$name\t$cost\t$qty\n\n"); fclose($fp); $fName = "item.csv"; $fp = fopen($fName, "r") or die("File not found/opened!"); $delimiter = ','; $totalCost = 0.00; print("<font face = \"Lucida Console\" size = \"3\" >"); printf("%30s", "Item Inventory\n"); printf("%5s \t %-14s \t %6s \t %-3s\n", "id", "name", "cost", "qty"); while ($item = fgetcsv($fp, $delimiter) ) { // 5 $id = $item[0]; $name = $item[1]; $cost = $item[2]; $qty = $item[3]; printf("%5d \t %-14s \t %6.2f \t %1d\n", $id, $name, $cost, $qty); $totalCost += $cost; } printf("%31s %7.2f", "total cost:", $totalCost); fclose($fp); ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 11
Branch analysis from position: 20
2 jumps found. (Code = 47) Position 1 = 80, Position 2 = 82
Branch analysis from position: 80
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 82
1 jumps found. (Code = 42) Position 1 = 113
Branch analysis from position: 113
2 jumps found. (Code = 44) Position 1 = 119, Position 2 = 97
Branch analysis from position: 119
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 97
2 jumps found. (Code = 44) Position 1 = 119, Position 2 = 97
Branch analysis from position: 119
Branch analysis from position: 97
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 11
Branch analysis from position: 20
Branch analysis from position: 11
filename:       /in/eGWD1
function name:  (null)
number of ops:  128
compiled vars:  !0 = $fName, !1 = $fp, !2 = $lineCount, !3 = $lineIn, !4 = $id, !5 = $name, !6 = $cost, !7 = $qty, !8 = $delimiter, !9 = $totalCost, !10 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'item.txt'
    3     1        INIT_FCALL                                               'fopen'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 'r'
          4        DO_ICALL                                         $12     
          5        ASSIGN                                           ~13     !1, $12
          6      > JMPNZ_EX                                         ~13     ~13, ->9
          7    > > EXIT                                                     'File+not+found%2Fopened%21'
          8*       BOOL                                             ~13     <true>
    4     9    >   ASSIGN                                                   !2, 0
    5    10      > JMP                                                      ->15
    6    11    >   NOP                                                      
         12        FAST_CONCAT                                      ~15     !3, '+%3Cbr%2F%3E'
         13        ECHO                                                     ~15
    7    14        PRE_INC                                                  !2
    5    15    >   INIT_FCALL                                               'fgets'
         16        SEND_VAR                                                 !1
         17        DO_ICALL                                         $17     
         18        ASSIGN                                           ~18     !3, $17
         19      > JMPNZ                                                    ~18, ->11
    9    20    >   ROPE_INIT                                     3  ~20     'line+count+%3D+'
         21        ROPE_ADD                                      1  ~20     ~20, !2
         22        ROPE_END                                      2  ~19     ~20, '%3Cbr%2F%3E%3Cbr%2F%3E'
         23        ECHO                                                     ~19
   10    24        INIT_FCALL                                               'fclose'
         25        SEND_VAR                                                 !1
         26        DO_ICALL                                                 
   12    27        INIT_FCALL                                               'fopen'
         28        SEND_VAR                                                 !0
         29        SEND_VAL                                                 'r'
         30        DO_ICALL                                         $23     
         31        ASSIGN                                                   !1, $23
   13    32        INIT_FCALL                                               'fgets'
         33        SEND_VAR                                                 !1
         34        DO_ICALL                                         $25     
         35        ASSIGN                                                   !3, $25
   14    36        INIT_FCALL                                               'substr'
         37        SEND_VAR                                                 !3
         38        SEND_VAL                                                 0
         39        SEND_VAL                                                 5
         40        DO_ICALL                                         $27     
         41        ASSIGN                                                   !4, $27
   15    42        INIT_FCALL                                               'substr'
         43        SEND_VAR                                                 !3
         44        SEND_VAL                                                 6
         45        SEND_VAL                                                 14
         46        DO_ICALL                                         $29     
         47        ASSIGN                                                   !5, $29
   16    48        INIT_FCALL                                               'substr'
         49        SEND_VAR                                                 !3
         50        SEND_VAL                                                 21
         51        SEND_VAL                                                 6
         52        DO_ICALL                                         $31     
         53        ASSIGN                                                   !6, $31
   17    54        INIT_FCALL                                               'substr'
         55        SEND_VAR                                                 !3
         56        SEND_VAL                                                 28
         57        SEND_VAL                                                 1
         58        DO_ICALL                                         $33     
         59        ASSIGN                                                   !7, $33
   18    60        ECHO                                                     '%3Cpre%3E'
   19    61        ROPE_INIT                                     8  ~36     !4
         62        ROPE_ADD                                      1  ~36     ~36, '%09'
         63        ROPE_ADD                                      2  ~36     ~36, !5
         64        ROPE_ADD                                      3  ~36     ~36, '%09'
         65        ROPE_ADD                                      4  ~36     ~36, !6
         66        ROPE_ADD                                      5  ~36     ~36, '%09'
         67        ROPE_ADD                                      6  ~36     ~36, !7
         68        ROPE_END                                      7  ~35     ~36, '%0A%0A'
         69        ECHO                                                     ~35
   20    70        INIT_FCALL                                               'fclose'
         71        SEND_VAR                                                 !1
         72        DO_ICALL                                                 
   22    73        ASSIGN                                                   !0, 'item.csv'
   23    74        INIT_FCALL                                               'fopen'
         75        SEND_VAR                                                 !0
         76        SEND_VAL                                                 'r'
         77        DO_ICALL                                         $42     
         78        ASSIGN                                           ~43     !1, $42
         79      > JMPNZ_EX                                         ~43     ~43, ->82
         80    > > EXIT                                                     'File+not+found%2Fopened%21'
         81*       BOOL                                             ~43     <true>
   24    82    >   ASSIGN                                                   !8, '%2C'
   25    83        ASSIGN                                                   !9, 0
   26    84        ECHO                                                     '%3Cfont+face+%3D+%22Lucida+Console%22+size+%3D+%223%22+%3E'
   27    85        INIT_FCALL                                               'printf'
         86        SEND_VAL                                                 '%2530s'
         87        SEND_VAL                                                 'Item+Inventory%0A'
         88        DO_ICALL                                                 
   28    89        INIT_FCALL                                               'printf'
         90        SEND_VAL                                                 '%255s+%09+%25-14s+%09+%256s+%09+%25-3s%0A'
         91        SEND_VAL                                                 'id'
         92        SEND_VAL                                                 'name'
         93        SEND_VAL                                                 'cost'
         94        SEND_VAL                                                 'qty'
         95        DO_ICALL                                                 
   29    96      > JMP                                                      ->113
   30    97    >   FETCH_DIM_R                                      ~48     !10, 0
         98        ASSIGN                                                   !4, ~48
   31    99        FETCH_DIM_R                                      ~50     !10, 1
        100        ASSIGN                                                   !5, ~50
   32   101        FETCH_DIM_R                                      ~52     !10, 2
        102        ASSIGN                                                   !6, ~52
   33   103        FETCH_DIM_R                                      ~54     !10, 3
        104        ASSIGN                                                   !7, ~54
   34   105        INIT_FCALL                                               'printf'
        106        SEND_VAL                                                 '%255d+%09+%25-14s+%09+%256.2f+%09+%251d%0A'
        107        SEND_VAR                                                 !4
        108        SEND_VAR                                                 !5
        109        SEND_VAR                                                 !6
        110        SEND_VAR                                                 !7
        111        DO_ICALL                                                 
   35   112        ASSIGN_OP                                     1          !9, !6
   29   113    >   INIT_FCALL                                               'fgetcsv'
        114        SEND_VAR                                                 !1
        115        SEND_VAR                                                 !8
        116        DO_ICALL                                         $58     
        117        ASSIGN                                           ~59     !10, $58
        118      > JMPNZ                                                    ~59, ->97
   37   119    >   INIT_FCALL                                               'printf'
        120        SEND_VAL                                                 '%2531s+%257.2f'
        121        SEND_VAL                                                 'total+cost%3A'
        122        SEND_VAR                                                 !9
        123        DO_ICALL                                                 
   38   124        INIT_FCALL                                               'fclose'
        125        SEND_VAR                                                 !1
        126        DO_ICALL                                                 
   40   127      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.62 ms | 1404 KiB | 25 Q