3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyClass { const MY_CONST = 'value'; // 常量 static $staticVar = 'static'; // 属性必须声明其作用域 public $property = 'public'; public $instanceProp; protected $prot = 'protected'; // 当前类和子类可访问 private $priv = 'private'; // 仅当前类可访问 // 通过 __construct 来定义构造函数 public function __construct($instanceProp) { // 通过 $this 访问当前对象 $this->instanceProp = $instanceProp; } // 方法就是类中定义的函数 public function myMethod() { print 'MyClass'; } final function youCannotOverrideMe() { } public static function myStaticMethod() { print 'I am static'; } } echo MyClass::MY_CONST; // 输出 'value'; echo MyClass::$staticVar; // 输出 'static'; MyClass::myStaticMethod(); // 输出 'I am static';
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oPvvJ
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   ECHO                                                     'value'
   37     1        FETCH_STATIC_PROP_R          unknown             ~0      'staticVar'
          2        ECHO                                                     ~0
   38     3        INIT_STATIC_METHOD_CALL                                  'MyClass', 'myStaticMethod'
          4        DO_FCALL                                      0          
          5      > RETURN                                                   1

Class MyClass:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oPvvJ
function name:  __construct
number of ops:  4
compiled vars:  !0 = $instanceProp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   17     1        ASSIGN_OBJ                                               'instanceProp'
          2        OP_DATA                                                  !0
   18     3      > RETURN                                                   null

End of function __construct

Function mymethod:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oPvvJ
function name:  myMethod
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   ECHO                                                     'MyClass'
   24     1      > RETURN                                                   null

End of function mymethod

Function youcannotoverrideme:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oPvvJ
function name:  youCannotOverrideMe
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E > > RETURN                                                   null

End of function youcannotoverrideme

Function mystaticmethod:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oPvvJ
function name:  myStaticMethod
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   ECHO                                                     'I+am+static'
   33     1      > RETURN                                                   null

End of function mystaticmethod

End of class MyClass.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.65 ms | 1395 KiB | 13 Q