3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SimDB { private static $count = 0; public static function mysqli_fetch_array($result) { if (self::$count < 10) { self::$count++; return "Row" . self::$count; } else { return false; } } public static function reset() { self::$count = 0; } } $result1 = ""; // This is simulated, so not an actual result set resource while ($row1 = SimDB::mysqli_fetch_array($result1)); echo "Value of \$row1 => $row1\n\n"; echo "Actually store all the results\n"; SimDB::reset(); while ($row1[] = SimDB::mysqli_fetch_array($result1)); var_dump($row1); echo "\n\n How you would actually use a while() loop\n\n"; SimDB::reset(); while ($row = SimDB::mysqli_fetch_array($result1)) { echo "Row = $row\n"; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 7, Position 2 = 2
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 15
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 28
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 28
Branch analysis from position: 37
Branch analysis from position: 28
Branch analysis from position: 15
Branch analysis from position: 2
filename:       /in/Z3Q3i
function name:  (null)
number of ops:  38
compiled vars:  !0 = $result1, !1 = $row1, !2 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   ASSIGN                                                   !0, ''
   21     1      > JMP                                                      ->2
          2    >   INIT_STATIC_METHOD_CALL                                  'SimDB', 'mysqli_fetch_array'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $4      
          5        ASSIGN                                           ~5      !1, $4
          6      > JMPNZ                                                    ~5, ->2
   23     7    >   ROPE_INIT                                     3  ~7      'Value+of+%24row1+%3D%3E+'
          8        ROPE_ADD                                      1  ~7      ~7, !1
          9        ROPE_END                                      2  ~6      ~7, '%0A%0A'
         10        ECHO                                                     ~6
   25    11        ECHO                                                     'Actually+store+all+the+results%0A'
   27    12        INIT_STATIC_METHOD_CALL                                  'SimDB', 'reset'
         13        DO_FCALL                                      0          
   29    14      > JMP                                                      ->15
         15    >   INIT_STATIC_METHOD_CALL                                  'SimDB', 'mysqli_fetch_array'
         16        SEND_VAR                                                 !0
         17        DO_FCALL                                      0  $11     
         18        ASSIGN_DIM                                       ~10     !1
         19        OP_DATA                                                  $11
         20      > JMPNZ                                                    ~10, ->15
   31    21    >   INIT_FCALL                                               'var_dump'
         22        SEND_VAR                                                 !1
         23        DO_ICALL                                                 
   33    24        ECHO                                                     '%0A%0A+How+you+would+actually+use+a+while%28%29+loop%0A%0A'
   35    25        INIT_STATIC_METHOD_CALL                                  'SimDB', 'reset'
         26        DO_FCALL                                      0          
   37    27      > JMP                                                      ->32
   38    28    >   ROPE_INIT                                     3  ~15     'Row+%3D+'
         29        ROPE_ADD                                      1  ~15     ~15, !2
         30        ROPE_END                                      2  ~14     ~15, '%0A'
         31        ECHO                                                     ~14
   37    32    >   INIT_STATIC_METHOD_CALL                                  'SimDB', 'mysqli_fetch_array'
         33        SEND_VAR                                                 !0
         34        DO_FCALL                                      0  $17     
         35        ASSIGN                                           ~18     !2, $17
         36      > JMPNZ                                                    ~18, ->28
   39    37    > > RETURN                                                   1

Class SimDB:
Function mysqli_fetch_array:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Z3Q3i
function name:  mysqli_fetch_array
number of ops:  11
compiled vars:  !0 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        FETCH_STATIC_PROP_R          unknown             ~1      'count'
          2        IS_SMALLER                                               ~1, 10
          3      > JMPZ                                                     ~2, ->9
    8     4    >   PRE_INC_STATIC_PROP                                      'count'
    9     5        FETCH_STATIC_PROP_R          unknown             ~4      'count'
          6        CONCAT                                           ~5      'Row', ~4
          7      > RETURN                                                   ~5
          8*       JMP                                                      ->10
   11     9    > > RETURN                                                   <false>
   13    10*     > RETURN                                                   null

End of function mysqli_fetch_array

Function reset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Z3Q3i
function name:  reset
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   ASSIGN_STATIC_PROP                                       'count'
          1        OP_DATA                                                  0
   17     2      > RETURN                                                   null

End of function reset

End of class SimDB.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
130.95 ms | 1405 KiB | 15 Q