3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Person { public static $company = 'TechBase VietNam'; public function getFriends() { return [ 'John' => function () { return 'John is my best friend!'; }, 'Alan' => function () { return 'Alan is old friend!'; } ]; } public function getFriendsOf($someone) { return $this->getFriends()[$someone](); } public static function getNewPerson() { return new Person(); } } // Create instance $person = new Person(); // Get friend echo "\n" . $person->getFriends()['John']() . "\n"; echo "\n" . $person->getFriendsOf('Alan') . "\n"; // Get company echo "\n" . $person::getNewPerson()::$company . "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CnaXt
function name:  (null)
number of ops:  26
compiled vars:  !0 = $person
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   NEW                                              $1      'Person'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   27     3        INIT_METHOD_CALL                                         !0, 'getFriends'
          4        DO_FCALL                                      0  $4      
          5        FETCH_DIM_R                                      ~5      $4, 'John'
          6        INIT_DYNAMIC_CALL                                        ~5
          7        DO_FCALL                                      0  $6      
          8        CONCAT                                           ~7      '%0A', $6
          9        CONCAT                                           ~8      ~7, '%0A'
         10        ECHO                                                     ~8
   28    11        INIT_METHOD_CALL                                         !0, 'getFriendsOf'
         12        SEND_VAL_EX                                              'Alan'
         13        DO_FCALL                                      0  $9      
         14        CONCAT                                           ~10     '%0A', $9
         15        CONCAT                                           ~11     ~10, '%0A'
         16        ECHO                                                     ~11
   31    17        FETCH_CLASS                                   0  $12     !0
         18        INIT_STATIC_METHOD_CALL                                  $12, 'getNewPerson'
         19        DO_FCALL                                      0  $13     
         20        FETCH_CLASS                                   0  $14     $13
         21        FETCH_STATIC_PROP_R          unknown             ~15     'company'
         22        CONCAT                                           ~16     '%0A', ~15
         23        CONCAT                                           ~17     ~16, '%0A'
         24        ECHO                                                     ~17
         25      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FCnaXt%3A6%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CnaXt
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E > > RETURN                                                   'John+is+my+best+friend%21'
    8     1*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FCnaXt%3A6%240

Function %00%7Bclosure%7D%2Fin%2FCnaXt%3A9%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CnaXt
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E > > RETURN                                                   'Alan+is+old+friend%21'
   11     1*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FCnaXt%3A9%241

Class Person:
Function getfriends:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CnaXt
function name:  getFriends
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FCnaXt%3A6%240'
    8     1        INIT_ARRAY                                       ~1      ~0, 'John'
    9     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FCnaXt%3A9%241'
   11     3        ADD_ARRAY_ELEMENT                                ~1      ~2, 'Alan'
          4      > RETURN                                                   ~1
   13     5*     > RETURN                                                   null

End of function getfriends

Function getfriendsof:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CnaXt
function name:  getFriendsOf
number of ops:  8
compiled vars:  !0 = $someone
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   16     1        INIT_METHOD_CALL                                         'getFriends'
          2        DO_FCALL                                      0  $1      
          3        FETCH_DIM_R                                      ~2      $1, !0
          4        INIT_DYNAMIC_CALL                                        ~2
          5        DO_FCALL                                      0  $3      
          6      > RETURN                                                   $3
   17     7*     > RETURN                                                   null

End of function getfriendsof

Function getnewperson:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CnaXt
function name:  getNewPerson
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   NEW                                              $0      'Person'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   $0
   21     3*     > RETURN                                                   null

End of function getnewperson

End of class Person.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.66 ms | 1399 KiB | 13 Q