3v4l.org

run code in 300+ PHP versions simultaneously
<?php function grep($pattern) { echo "Looking for $pattern\n"; while (true) { $line = (yield); if (false !== strpos($line, $pattern)) { echo "$line\n"; } } } // Imagine we parsed a file which returned the following lines. $lines = array( "<?php\n", "echo 'toto';", ); $g = grep('php'); foreach ($lines as $line) { $g->send($line); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 11
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/3CtMI
function name:  (null)
number of ops:  13
compiled vars:  !0 = $lines, !1 = $g, !2 = $line
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   ASSIGN                                                   !0, <array>
   18     1        INIT_FCALL                                               'grep'
          2        SEND_VAL                                                 'php'
          3        DO_FCALL                                      0  $4      
          4        ASSIGN                                                   !1, $4
   19     5      > FE_RESET_R                                       $6      !0, ->11
          6    > > FE_FETCH_R                                               $6, !2, ->11
   20     7    >   INIT_METHOD_CALL                                         !1, 'send'
          8        SEND_VAR_EX                                              !2
          9        DO_FCALL                                      0          
   19    10      > JMP                                                      ->6
         11    >   FE_FREE                                                  $6
   21    12      > RETURN                                                   1

Function grep:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 7
Branch analysis from position: 19
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 18
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 7
Branch analysis from position: 19
Branch analysis from position: 7
Branch analysis from position: 18
filename:       /in/3CtMI
function name:  grep
number of ops:  20
compiled vars:  !0 = $pattern, !1 = $line
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
    4     2        ROPE_INIT                                     3  ~3      'Looking+for+'
          3        ROPE_ADD                                      1  ~3      ~3, !0
          4        ROPE_END                                      2  ~2      ~3, '%0A'
          5        ECHO                                                     ~2
    5     6      > JMP                                                      ->18
    6     7    >   YIELD                                            $5      
          8        ASSIGN                                                   !1, $5
    7     9        INIT_FCALL                                               'strpos'
         10        SEND_VAR                                                 !1
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $7      
         13        TYPE_CHECK                                  1018          $7
         14      > JMPZ                                                     ~8, ->18
    8    15    >   NOP                                                      
         16        FAST_CONCAT                                      ~9      !1, '%0A'
         17        ECHO                                                     ~9
    5    18    > > JMPNZ                                                    <true>, ->7
   11    19    > > GENERATOR_RETURN                                         

End of function grep

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.18 ms | 1403 KiB | 16 Q