3v4l.org

run code in 300+ PHP versions simultaneously
<?php // This is the best that you can do in PHP without going into the weird // self-modifying code because of this: // https://wiki.php.net/rfc/uniform_variable_syntax // I've inclued two ways of doing it, one using concat (.) and one using method // calls (->). If the UVS thing passes we can replace the the zero-width space // in the Container class w/ an __invoke() call and all will be well. class Container { private $current_string = "g"; public function __invoke($str = null) { if ($str !== null) { return $this->current_string . $str; } $this->current_string .= "o"; return $this; } } function gg($str = null) { if ($str === "al") { return "gal"; } return new Container(); } function g($str = null) { return "g" . $str; } function ​($str = null) { return $str ?: "o"; } return gg()()("al");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sqKTm
function name:  (null)
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   INIT_FCALL                                               'gg'
          1        DO_FCALL                                      0  $0      
          2        INIT_DYNAMIC_CALL                                        $0
          3        DO_FCALL                                      0  $1      
          4        INIT_DYNAMIC_CALL                                        $1
          5        SEND_VAL_EX                                              'al'
          6        DO_FCALL                                      0  $2      
          7      > RETURN                                                   $2
          8*     > RETURN                                                   1

Function gg:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 4
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sqKTm
function name:  gg
number of ops:  8
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV_INIT                                        !0      null
   29     1        IS_IDENTICAL                                             !0, 'al'
          2      > JMPZ                                                     ~1, ->4
   30     3    > > RETURN                                                   'gal'
   33     4    >   NEW                                              $2      'Container'
          5        DO_FCALL                                      0          
          6      > RETURN                                                   $2
   34     7*     > RETURN                                                   null

End of function gg

Function g:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sqKTm
function name:  g
number of ops:  4
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   RECV_INIT                                        !0      null
   38     1        CONCAT                                           ~1      'g', !0
          2      > RETURN                                                   ~1
   39     3*     > RETURN                                                   null

End of function g

Function %E2%80%8B:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sqKTm
function name:  ​
number of ops:  5
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   RECV_INIT                                        !0      null
   42     1        JMP_SET                                          ~1      !0, ->3
          2        QM_ASSIGN                                        ~1      'o'
          3      > RETURN                                                   ~1
   43     4*     > RETURN                                                   null

End of function %E2%80%8B

Class Container:
Function __invoke:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sqKTm
function name:  __invoke
number of ops:  11
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV_INIT                                        !0      null
   17     1        TYPE_CHECK                                  1020          !0
          2      > JMPZ                                                     ~1, ->6
   18     3    >   FETCH_OBJ_R                                      ~2      'current_string'
          4        CONCAT                                           ~3      ~2, !0
          5      > RETURN                                                   ~3
   21     6    >   ASSIGN_OBJ_OP                                 8          'current_string'
          7        OP_DATA                                                  'o'
   23     8        FETCH_THIS                                       ~5      
          9      > RETURN                                                   ~5
   24    10*     > RETURN                                                   null

End of function __invoke

End of class Container.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.82 ms | 1407 KiB | 14 Q