3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface Randomizer { public function randomize(); } class PHPRandRandomizer implements Randomizer { public function randomize() { return rand(1, 10); } } class LetterRandomizer implements Randomizer { private $letters = array('a','b','c','d','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'); public function randomize() { echo $this->letters[rand(1,24)]; } } class Matrix { private $randomizer; private $running = false; private $counter = 0; public function __construct(Randomizer $randomizer) { $this->randomizer = $randomizer; } public function start() { $this->running = true; $this->run(); } public function stop() { $this->running = false; } public function run() { while($this->running) { $this->counter++; // Alles in de console heel snel na elkaar uit echo'en om een matrix effect te creeƫren. echo $this->randomizer->randomize(); if ($this->counter > 50000000) { // De matrix stopt na een x aantal keren. $this->stop(); } } } } $matrix = new Matrix(new LetterRandomizer); // Hier gebruiken we een letter randomizer, maar je kan ook de PHPRandRandomizer gebruiken, met cijfertjes. $matrix->start();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jsLgT
function name:  (null)
number of ops:  11
compiled vars:  !0 = $matrix
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   DECLARE_CLASS                                            'phprandrandomizer'
   13     1        DECLARE_CLASS                                            'letterrandomizer'
   54     2        NEW                                              $1      'Matrix'
          3        NEW                                              $2      'LetterRandomizer'
          4        DO_FCALL                                      0          
          5        SEND_VAR_NO_REF_EX                                       $2
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !0, $1
   55     8        INIT_METHOD_CALL                                         !0, 'start'
          9        DO_FCALL                                      0          
         10      > RETURN                                                   1

Class Randomizer:
Function randomize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jsLgT
function name:  randomize
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E > > RETURN                                                   null

End of function randomize

End of class Randomizer.

Class PHPRandRandomizer:
Function randomize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jsLgT
function name:  randomize
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                               'rand'
          1        SEND_VAL                                                 1
          2        SEND_VAL                                                 10
          3        DO_ICALL                                         $0      
          4      > RETURN                                                   $0
   10     5*     > RETURN                                                   null

End of function randomize

End of class PHPRandRandomizer.

Class LetterRandomizer:
Function randomize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jsLgT
function name:  randomize
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL                                               'rand'
          1        SEND_VAL                                                 1
          2        SEND_VAL                                                 24
          3        DO_ICALL                                         $1      
          4        FETCH_OBJ_R                                      ~0      'letters'
          5        FETCH_DIM_R                                      ~2      ~0, $1
          6        ECHO                                                     ~2
   18     7      > RETURN                                                   null

End of function randomize

End of class LetterRandomizer.

Class Matrix:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jsLgT
function name:  __construct
number of ops:  4
compiled vars:  !0 = $randomizer
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
   27     1        ASSIGN_OBJ                                               'randomizer'
          2        OP_DATA                                                  !0
   28     3      > RETURN                                                   null

End of function __construct

Function start:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jsLgT
function name:  start
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   ASSIGN_OBJ                                               'running'
          1        OP_DATA                                                  <true>
   33     2        INIT_METHOD_CALL                                         'run'
          3        DO_FCALL                                      0          
   34     4      > RETURN                                                   null

End of function start

Function stop:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jsLgT
function name:  stop
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   ASSIGN_OBJ                                               'running'
          1        OP_DATA                                                  <false>
   38     2      > RETURN                                                   null

End of function stop

Function run:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 1
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 1
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 1
Branch analysis from position: 13
Branch analysis from position: 1
Branch analysis from position: 11
filename:       /in/jsLgT
function name:  run
number of ops:  14
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E > > JMP                                                      ->11
   42     1    >   PRE_INC_OBJ                                              'counter'
   45     2        FETCH_OBJ_R                                      ~1      'randomizer'
          3        INIT_METHOD_CALL                                         ~1, 'randomize'
          4        DO_FCALL                                      0  $2      
          5        ECHO                                                     $2
   47     6        FETCH_OBJ_R                                      ~3      'counter'
          7        IS_SMALLER                                               50000000, ~3
          8      > JMPZ                                                     ~4, ->11
   48     9    >   INIT_METHOD_CALL                                         'stop'
         10        DO_FCALL                                      0          
   41    11    >   FETCH_OBJ_R                                      ~6      'running'
         12      > JMPNZ                                                    ~6, ->1
   51    13    > > RETURN                                                   null

End of function run

End of class Matrix.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.15 ms | 1400 KiB | 15 Q