3v4l.org

run code in 300+ PHP versions simultaneously
<?php class My{ function prepare($text){ return preg_replace( '/\{(.+?)\}/', $this->rand(explode('|', '\\1')), $text ); } private function rand(array $values){ return $values[rand(0, sizeof($values)-1)]; } } echo (new My)->prepare('i choose {ps3|games}');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Vt5FI
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   NEW                                              $0      'My'
          1        DO_FCALL                                      0          
          2        INIT_METHOD_CALL                                         $0, 'prepare'
          3        SEND_VAL_EX                                              'i+choose+%7Bps3%7Cgames%7D'
          4        DO_FCALL                                      0  $2      
          5        ECHO                                                     $2
          6      > RETURN                                                   1

Class My:
Function prepare:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Vt5FI
function name:  prepare
number of ops:  15
compiled vars:  !0 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'preg_replace'
    5     2        SEND_VAL                                                 '%2F%5C%7B%28.%2B%3F%29%5C%7D%2F'
    6     3        INIT_METHOD_CALL                                         'rand'
          4        INIT_FCALL                                               'explode'
          5        SEND_VAL                                                 '%7C'
          6        SEND_VAL                                                 '%5C1'
          7        DO_ICALL                                         $1      
          8        SEND_VAR_NO_REF_EX                                       $1
          9        DO_FCALL                                      0  $2      
         10        SEND_VAR                                                 $2
    7    11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $3      
         13      > RETURN                                                   $3
    9    14*     > RETURN                                                   null

End of function prepare

Function rand:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Vt5FI
function name:  rand
number of ops:  10
compiled vars:  !0 = $values
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        INIT_FCALL                                               'rand'
          2        SEND_VAL                                                 0
          3        COUNT                                            ~1      !0
          4        SUB                                              ~2      ~1, 1
          5        SEND_VAL                                                 ~2
          6        DO_ICALL                                         $3      
          7        FETCH_DIM_R                                      ~4      !0, $3
          8      > RETURN                                                   ~4
   12     9*     > RETURN                                                   null

End of function rand

End of class My.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
220.4 ms | 1396 KiB | 19 Q