3v4l.org

run code in 300+ PHP versions simultaneously
<?php define( 'ANIMAL', 'turtles!' ); $constant = constant(...); echo "I like {$constant('ANIMAL')}"; echo PHP_EOL; echo PHP_EOL; $fn = 'substr'; echo "I like {$fn('turtles!', 0, -1)}"; echo PHP_EOL; echo PHP_EOL; $escape = fn( $string ) => htmlspecialchars( (string) $string, ENT_QUOTES, 'utf-8' ); $userText = "<script>alert('xss')</script>"; echo "You entered {$escape( $userText )}"; echo PHP_EOL; echo PHP_EOL; class Arr { public static function get( $array, $key, $default = null ) { return is_array( $array ) && array_key_exists( $key, $array ) ? $array[$key] : $default; } } $fn = array( 'Arr', 'get' ); echo "I like {$fn(['turtles'], 0)}!";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/N3AR5
function name:  (null)
number of ops:  47
compiled vars:  !0 = $constant, !1 = $fn, !2 = $escape, !3 = $userText
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'define'
          1        SEND_VAL                                                 'ANIMAL'
          2        SEND_VAL                                                 'turtles%21'
          3        DO_ICALL                                                 
    4     4        INIT_FCALL                                               'constant'
          5        ZEND_CALLABLE_CONVERT                            ~5      
          6        ASSIGN                                                   !0, ~5
    6     7        NOP                                                      
          8        INIT_DYNAMIC_CALL                                        !0
          9        SEND_VAL_EX                                              'ANIMAL'
         10        DO_FCALL                                      0  $7      
         11        FAST_CONCAT                                      ~8      'I+like+', $7
         12        ECHO                                                     ~8
    8    13        ECHO                                                     '%0A'
    9    14        ECHO                                                     '%0A'
   11    15        ASSIGN                                                   !1, 'substr'
   13    16        NOP                                                      
         17        INIT_DYNAMIC_CALL                                        !1
         18        SEND_VAL_EX                                              'turtles%21'
         19        SEND_VAL_EX                                              0
         20        SEND_VAL_EX                                              -1
         21        DO_FCALL                                      0  $10     
         22        FAST_CONCAT                                      ~11     'I+like+', $10
         23        ECHO                                                     ~11
   15    24        ECHO                                                     '%0A'
   16    25        ECHO                                                     '%0A'
   18    26        DECLARE_LAMBDA_FUNCTION                          ~12     [0]
         27        ASSIGN                                                   !2, ~12
   19    28        ASSIGN                                                   !3, '%3Cscript%3Ealert%28%27xss%27%29%3C%2Fscript%3E'
   21    29        NOP                                                      
         30        INIT_DYNAMIC_CALL                                        !2
         31        SEND_VAR_EX                                              !3
         32        DO_FCALL                                      0  $15     
         33        FAST_CONCAT                                      ~16     'You+entered+', $15
         34        ECHO                                                     ~16
   23    35        ECHO                                                     '%0A'
   24    36        ECHO                                                     '%0A'
   36    37        ASSIGN                                                   !1, <array>
   38    38        ROPE_INIT                                     3  ~20     'I+like+'
         39        INIT_DYNAMIC_CALL                                        !1
         40        SEND_VAL_EX                                              <array>
         41        SEND_VAL_EX                                              0
         42        DO_FCALL                                      0  $18     
         43        ROPE_ADD                                      1  ~20     ~20, $18
         44        ROPE_END                                      2  ~19     ~20, '%21'
         45        ECHO                                                     ~19
         46      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/N3AR5
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'htmlspecialchars'
          2        CAST                                          6  ~1      !0
          3        SEND_VAL                                                 ~1
          4        SEND_VAL                                                 3
          5        SEND_VAL                                                 'utf-8'
          6        DO_ICALL                                         $2      
          7      > RETURN                                                   $2
          8*     > RETURN                                                   null

End of Dynamic Function 0

Class Arr:
Function get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/N3AR5
function name:  get
number of ops:  14
compiled vars:  !0 = $array, !1 = $key, !2 = $default
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      null
   30     3        TYPE_CHECK                                  128  ~3      !0
          4      > JMPZ_EX                                          ~3      ~3, ->7
          5    >   ARRAY_KEY_EXISTS                                 ~4      !1, !0
          6        BOOL                                             ~3      ~4
          7    > > JMPZ                                                     ~3, ->11
   31     8    >   FETCH_DIM_R                                      ~5      !0, !1
          9        QM_ASSIGN                                        ~6      ~5
         10      > JMP                                                      ->12
   32    11    >   QM_ASSIGN                                        ~6      !2
         12    > > RETURN                                                   ~6
   33    13*     > RETURN                                                   null

End of function get

End of class Arr.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
190.9 ms | 1017 KiB | 16 Q