3v4l.org

run code in 300+ PHP versions simultaneously
<?php class stdObject{ public function __construct(array $params=array()){ if(!empty($params)) foreach ($params as $key => $value) $this->{$key}=$value; } public function __call($methodName,$params){ $params=array_merge(array('stdObject'=>$this),$params); if(isset($this->{$methodName})&&is_callable($methodName)){ //$params就是函数的参数,这里的stdObject就是function中的$stdObject; return call_user_func_array($methodName,$params); } else { throw new Exception("Fatal error: Call to undefined method stdObject::{$methodName}()"); } } } echo phpversion(); $obj = new stdObject(); $obj->name = "Nick"; $obj->surname = "Doe"; $obj->age = 20; $obj->adresse = null; $obj->getInfo = function($stdObject) { // $stdObject referred to this object (stdObject). echo $stdObject->name . " " . $stdObject->surname . " have " . $stdObject->age . " yrs old. And live in " . $stdObject->adresse; }; print_r($obj); $obj->getInfo();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mLlqC
function name:  (null)
number of ops:  23
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_FCALL                                               'phpversion'
          1        DO_ICALL                                         $1      
          2        ECHO                                                     $1
   22     3        NEW                                              $2      'stdObject'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $2
   23     6        ASSIGN_OBJ                                               !0, 'name'
          7        OP_DATA                                                  'Nick'
   24     8        ASSIGN_OBJ                                               !0, 'surname'
          9        OP_DATA                                                  'Doe'
   25    10        ASSIGN_OBJ                                               !0, 'age'
         11        OP_DATA                                                  20
   26    12        ASSIGN_OBJ                                               !0, 'adresse'
         13        OP_DATA                                                  null
   27    14        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FmLlqC%3A27%240'
         15        ASSIGN_OBJ                                               !0, 'getInfo'
   30    16        OP_DATA                                                  ~10
   32    17        INIT_FCALL                                               'print_r'
         18        SEND_VAR                                                 !0
         19        DO_ICALL                                                 
   33    20        INIT_METHOD_CALL                                         !0, 'getInfo'
         21        DO_FCALL                                      0          
         22      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FmLlqC%3A27%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mLlqC
function name:  {closure}
number of ops:  13
compiled vars:  !0 = $stdObject
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
   29     1        FETCH_OBJ_R                                      ~1      !0, 'name'
          2        CONCAT                                           ~2      ~1, '+'
          3        FETCH_OBJ_R                                      ~3      !0, 'surname'
          4        CONCAT                                           ~4      ~2, ~3
          5        CONCAT                                           ~5      ~4, '+have+'
          6        FETCH_OBJ_R                                      ~6      !0, 'age'
          7        CONCAT                                           ~7      ~5, ~6
          8        CONCAT                                           ~8      ~7, '+yrs+old.+And+live+in+'
          9        FETCH_OBJ_R                                      ~9      !0, 'adresse'
         10        CONCAT                                           ~10     ~8, ~9
         11        ECHO                                                     ~10
   30    12      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FmLlqC%3A27%240

Class stdObject:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 11
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
Branch analysis from position: 11
filename:       /in/mLlqC
function name:  __construct
number of ops:  12
compiled vars:  !0 = $params, !1 = $value, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV_INIT                                        !0      <array>
    4     1        ISSET_ISEMPTY_CV                                 ~3      !0
          2        BOOL_NOT                                         ~4      ~3
          3      > JMPZ                                                     ~4, ->11
    5     4    > > FE_RESET_R                                       $5      !0, ->10
          5    > > FE_FETCH_R                                       ~6      $5, !1, ->10
          6    >   ASSIGN                                                   !2, ~6
    6     7        ASSIGN_OBJ                                               !2
          8        OP_DATA                                                  !1
    5     9      > JMP                                                      ->5
         10    >   FE_FREE                                                  $5
    7    11    > > RETURN                                                   null

End of function __construct

Function __call:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 11, Position 2 = 15
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 22
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 15
filename:       /in/mLlqC
function name:  __call
number of ops:  30
compiled vars:  !0 = $methodName, !1 = $params
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   10     2        INIT_FCALL                                               'array_merge'
          3        FETCH_THIS                                       ~2      
          4        INIT_ARRAY                                       ~3      ~2, 'stdObject'
          5        SEND_VAL                                                 ~3
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $4      
          8        ASSIGN                                                   !1, $4
   11     9        ISSET_ISEMPTY_PROP_OBJ                           ~6      !0
         10      > JMPZ_EX                                          ~6      ~6, ->15
         11    >   INIT_FCALL                                               'is_callable'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $7      
         14        BOOL                                             ~6      $7
         15    > > JMPZ                                                     ~6, ->22
   13    16    >   INIT_USER_CALL                                0          'call_user_func_array', !0
         17        SEND_ARRAY                                               !1
         18        CHECK_UNDEF_ARGS                                         
         19        DO_FCALL                                      0  $8      
         20      > RETURN                                                   $8
         21*       JMP                                                      ->29
   15    22    >   NEW                                              $9      'Exception'
         23        ROPE_INIT                                     3  ~11     'Fatal+error%3A+Call+to+undefined+method+stdObject%3A%3A'
         24        ROPE_ADD                                      1  ~11     ~11, !0
         25        ROPE_END                                      2  ~10     ~11, '%28%29'
         26        SEND_VAL_EX                                              ~10
         27        DO_FCALL                                      0          
         28      > THROW                                         0          $9
   17    29*     > RETURN                                                   null

End of function __call

End of class stdObject.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.79 ms | 1404 KiB | 21 Q