3v4l.org

run code in 300+ PHP versions simultaneously
<?php $name="why";//声明变量$name,并初始化 function echoName1() { //在函数echoName1()里使用global来声明$name global $name; echo "the first name is ".$name."<br>"; } function echoName2() { //在函数echoName2()里没有使用global来声明$name echo "the second name is ".$name."<br>"; } echoName1(); echoName2(); $last_name = "O'Keefe"; echo $sql = "select * from users where last_name = '" . addslashes($last_name) . "'"; class Person { //下面是人的成员属性 var $name; //人的名子 var $sex; //人的性别 var $age; //人的年龄 //定义一个构造方法参数为属性姓名$name、性别$sex和年龄$age进行赋值 function __construct($name = "", $sex = "", $age = "") { $this->name=$name; $this->sex=$sex; $this->age=$age; } //这个人可以说话的方法, 说出自己的属性 function say() { echo "我的名子叫:" . $this->name . " 性别:" . $this->sex . " 我的年龄是:" . $this->age . "<br>"; } //对象克隆时自动调用的方法, 如果想在克隆后改变原对象的内容,需要在__clone()中重写原本的属性和方法 function __clone() { //$this指的复本p2, 而$that是指向原本p1,这样就在本方法里,改变了复本的属性。 $this->name = "我是假的 $that->name"; $this->age = 30; } } $p1 = new Person("张三", "男", 20); $p2 = clone $p1; $p1->say(); $p2->say();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SjORJ
function name:  (null)
number of ops:  26
compiled vars:  !0 = $name, !1 = $last_name, !2 = $sql, !3 = $p1, !4 = $p2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ASSIGN                                                   !0, 'why'
   18     1        INIT_FCALL                                               'echoname1'
          2        DO_FCALL                                      0          
   19     3        INIT_FCALL                                               'echoname2'
          4        DO_FCALL                                      0          
   21     5        ASSIGN                                                   !1, 'O%27Keefe'
   22     6        INIT_FCALL                                               'addslashes'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $9      
          9        CONCAT                                           ~10     'select+%2A+from+users+where+last_name+%3D+%27', $9
         10        CONCAT                                           ~11     ~10, '%27'
         11        ASSIGN                                           ~12     !2, ~11
         12        ECHO                                                     ~12
   53    13        NEW                                              $13     'Person'
         14        SEND_VAL_EX                                              '%E5%BC%A0%E4%B8%89'
         15        SEND_VAL_EX                                              '%E7%94%B7'
         16        SEND_VAL_EX                                              20
         17        DO_FCALL                                      0          
         18        ASSIGN                                                   !3, $13
   54    19        CLONE                                            ~16     !3
         20        ASSIGN                                                   !4, ~16
   55    21        INIT_METHOD_CALL                                         !3, 'say'
         22        DO_FCALL                                      0          
   56    23        INIT_METHOD_CALL                                         !4, 'say'
         24        DO_FCALL                                      0          
         25      > RETURN                                                   1

Function echoname1:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SjORJ
function name:  echoName1
number of ops:  5
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   BIND_GLOBAL                                              !0, 'name'
   11     1        CONCAT                                           ~1      'the+first+name+is+', !0
          2        CONCAT                                           ~2      ~1, '%3Cbr%3E'
          3        ECHO                                                     ~2
   12     4      > RETURN                                                   null

End of function echoname1

Function echoname2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SjORJ
function name:  echoName2
number of ops:  4
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   CONCAT                                           ~1      'the+second+name+is+', !0
          1        CONCAT                                           ~2      ~1, '%3Cbr%3E'
          2        ECHO                                                     ~2
   17     3      > RETURN                                                   null

End of function echoname2

Class Person:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SjORJ
function name:  __construct
number of ops:  10
compiled vars:  !0 = $name, !1 = $sex, !2 = $age
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV_INIT                                        !0      ''
          1        RECV_INIT                                        !1      ''
          2        RECV_INIT                                        !2      ''
   33     3        ASSIGN_OBJ                                               'name'
          4        OP_DATA                                                  !0
   34     5        ASSIGN_OBJ                                               'sex'
          6        OP_DATA                                                  !1
   35     7        ASSIGN_OBJ                                               'age'
          8        OP_DATA                                                  !2
   36     9      > RETURN                                                   null

End of function __construct

Function say:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SjORJ
function name:  say
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   FETCH_OBJ_R                                      ~0      'name'
          1        CONCAT                                           ~1      '%E6%88%91%E7%9A%84%E5%90%8D%E5%AD%90%E5%8F%AB%EF%BC%9A', ~0
          2        CONCAT                                           ~2      ~1, '+%E6%80%A7%E5%88%AB%EF%BC%9A'
          3        FETCH_OBJ_R                                      ~3      'sex'
          4        CONCAT                                           ~4      ~2, ~3
          5        CONCAT                                           ~5      ~4, '+%E6%88%91%E7%9A%84%E5%B9%B4%E9%BE%84%E6%98%AF%EF%BC%9A'
          6        FETCH_OBJ_R                                      ~6      'age'
          7        CONCAT                                           ~7      ~5, ~6
          8        CONCAT                                           ~8      ~7, '%3Cbr%3E'
          9        ECHO                                                     ~8
   41    10      > RETURN                                                   null

End of function say

Function __clone:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SjORJ
function name:  __clone
number of ops:  8
compiled vars:  !0 = $that
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E >   NOP                                                      
          1        FETCH_OBJ_R                                      ~2      !0, 'name'
          2        FAST_CONCAT                                      ~3      '%E6%88%91%E6%98%AF%E5%81%87%E7%9A%84+', ~2
          3        ASSIGN_OBJ                                               'name'
          4        OP_DATA                                                  ~3
   48     5        ASSIGN_OBJ                                               'age'
          6        OP_DATA                                                  30
   49     7      > RETURN                                                   null

End of function __clone

End of class Person.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.83 ms | 1403 KiB | 17 Q