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 getFriendOf($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/qFETL
function name:  (null)
number of ops:  24
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        CONCAT                                           ~6      '%0A', ~5
          7        CONCAT                                           ~7      ~6, '%0A'
          8        ECHO                                                     ~7
   28     9        INIT_METHOD_CALL                                         !0, 'getFriendsOf'
         10        SEND_VAL_EX                                              'Alan'
         11        DO_FCALL                                      0  $8      
         12        CONCAT                                           ~9      '%0A', $8
         13        CONCAT                                           ~10     ~9, '%0A'
         14        ECHO                                                     ~10
   31    15        FETCH_CLASS                                   0  $11     !0
         16        INIT_STATIC_METHOD_CALL                                  $11, 'getNewPerson'
         17        DO_FCALL                                      0  $12     
         18        FETCH_CLASS                                   0  $13     $12
         19        FETCH_STATIC_PROP_R          unknown             ~14     'company'
         20        CONCAT                                           ~15     '%0A', ~14
         21        CONCAT                                           ~16     ~15, '%0A'
         22        ECHO                                                     ~16
         23      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FqFETL%3A6%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qFETL
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%2FqFETL%3A6%240

Function %00%7Bclosure%7D%2Fin%2FqFETL%3A9%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qFETL
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%2FqFETL%3A9%241

Class Person:
Function getfriends:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qFETL
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%2FqFETL%3A6%240'
    8     1        INIT_ARRAY                                       ~1      ~0, 'John'
    9     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FqFETL%3A9%241'
   11     3        ADD_ARRAY_ELEMENT                                ~1      ~2, 'Alan'
          4      > RETURN                                                   ~1
   13     5*     > RETURN                                                   null

End of function getfriends

Function getfriendof:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qFETL
function name:  getFriendOf
number of ops:  6
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      > RETURN                                                   ~2
   17     5*     > RETURN                                                   null

End of function getfriendof

Function getnewperson:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qFETL
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:
176.89 ms | 1399 KiB | 13 Q