3v4l.org

run code in 500+ PHP versions simultaneously
<?php trait PersonPL{ public function sayHello($name){ echo 'Witaj, nazywam siÄ™ '.$name; } public function whereFrom($country){ echo 'Jestem z '.$country; } } trait PersonENG{ public function sayHello($name){ echo 'Hi, my name is '.$name; } public function whereFrom($country){ echo 'I am form '.$country; } } trait SayHello{ private $language = "PL"; private $listLanguages = ["PL", "ENG"]; use PersonPL, PersonENG{ PersonPL::sayHello as sayHelloPL; PersonPL::whereFrom as whereFromPL; PersonENG::sayHello as sayHelloENG; PersonENG::whereFrom as whereFromENG; } public function sayHello($name){ $this->{'sayHello'.$this->language}($name); } public function whereFrom($country){ $this->{'whereFrom'.$this->language}($country); } public function setLanguage($language){ if(in_array(strtoupper($language), $this->listLanguages)){ $this->language = $language; } } } class TestA{ use SayHello; } $objectA = new TestA(); $objectA->sayHello("Anna"); $objectA->whereFrom("Polski"); echo " Wersja ENG: "; $objectA->setLanguage("ENG"); $objectA->sayHello("Anna"); $objectA->whereFrom("Poland");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5UENa
function name:  (null)
number of ops:  22
compiled vars:  !0 = $objectA
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   23     0  E >   DECLARE_CLASS                                                'sayhello'
   51     1        DECLARE_CLASS                                                'testa'
   55     2        NEW                                                  $1      'TestA'
          3        DO_FCALL                                          0          
          4        ASSIGN                                                       !0, $1
   56     5        INIT_METHOD_CALL                                             !0, 'sayHello'
          6        SEND_VAL_EX                                                  'Anna'
          7        DO_FCALL                                          0          
   57     8        INIT_METHOD_CALL                                             !0, 'whereFrom'
          9        SEND_VAL_EX                                                  'Polski'
         10        DO_FCALL                                          0          
   58    11        ECHO                                                         '+Wersja+ENG%3A+'
   59    12        INIT_METHOD_CALL                                             !0, 'setLanguage'
         13        SEND_VAL_EX                                                  'ENG'
         14        DO_FCALL                                          0          
   60    15        INIT_METHOD_CALL                                             !0, 'sayHello'
         16        SEND_VAL_EX                                                  'Anna'
         17        DO_FCALL                                          0          
   61    18        INIT_METHOD_CALL                                             !0, 'whereFrom'
         19        SEND_VAL_EX                                                  'Poland'
         20        DO_FCALL                                          0          
         21      > RETURN                                                       1

Class PersonPL:
Function sayhello:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5UENa
function name:  sayHello
number of ops:  4
compiled vars:  !0 = $name
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    4     0  E >   RECV                                                 !0      
    5     1        CONCAT                                               ~1      'Witaj%2C+nazywam+si%C4%99+', !0
          2        ECHO                                                         ~1
    6     3      > RETURN                                                       null

End of function sayhello

Function wherefrom:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5UENa
function name:  whereFrom
number of ops:  4
compiled vars:  !0 = $country
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   RECV                                                 !0      
    9     1        CONCAT                                               ~1      'Jestem+z+', !0
          2        ECHO                                                         ~1
   10     3      > RETURN                                                       null

End of function wherefrom

End of class PersonPL.

Class PersonENG:
Function sayhello:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5UENa
function name:  sayHello
number of ops:  4
compiled vars:  !0 = $name
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   RECV                                                 !0      
   15     1        CONCAT                                               ~1      'Hi%2C+my+name+is+', !0
          2        ECHO                                                         ~1
   16     3      > RETURN                                                       null

End of function sayhello

Function wherefrom:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5UENa
function name:  whereFrom
number of ops:  4
compiled vars:  !0 = $country
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   RECV                                                 !0      
   19     1        CONCAT                                               ~1      'I+am+form+', !0
          2        ECHO                                                         ~1
   20     3      > RETURN                                                       null

End of function wherefrom

End of class PersonENG.

Class SayHello:
Function sayhello:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5UENa
function name:  sayHello
number of ops:  7
compiled vars:  !0 = $name
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   36     0  E >   RECV                                                 !0      
   37     1        FETCH_OBJ_R                                          ~1      'language'
          2        CONCAT                                               ~2      'sayHello', ~1
          3        INIT_METHOD_CALL                                             ~2
          4        SEND_VAR_EX                                                  !0
          5        DO_FCALL                                          0          
   38     6      > RETURN                                                       null

End of function sayhello

Function wherefrom:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5UENa
function name:  whereFrom
number of ops:  7
compiled vars:  !0 = $country
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   40     0  E >   RECV                                                 !0      
   41     1        FETCH_OBJ_R                                          ~1      'language'
          2        CONCAT                                               ~2      'whereFrom', ~1
          3        INIT_METHOD_CALL                                             ~2
          4        SEND_VAR_EX                                                  !0
          5        DO_FCALL                                          0          
   42     6      > RETURN                                                       null

End of function wherefrom

Function setlanguage:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/5UENa
function name:  setLanguage
number of ops:  10
compiled vars:  !0 = $language
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   44     0  E >   RECV                                                 !0      
   45     1        INIT_FCALL                                                   'strtoupper'
          2        SEND_VAR                                                     !0
          3        DO_ICALL                                             $1      
          4        FETCH_OBJ_R                                          ~2      'listLanguages'
          5        FRAMELESS_ICALL_2                in_array            ~3      $1, ~2
          6      > JMPZ                                                         ~3, ->9
   46     7    >   ASSIGN_OBJ                                                   'language'
          8        OP_DATA                                                      !0
   48     9    > > RETURN                                                       null

End of function setlanguage

End of class SayHello.

Class TestA: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
170.05 ms | 2268 KiB | 14 Q