3v4l.org

run code in 300+ PHP versions simultaneously
<?php class person { var $name; // variable inside class = property function __construct($persons_name=null) { $this->name = $persons_name; } function set_name($new_name) { $this->name = $new_name; } function get_name() { // function inside class = method return $this->name; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta> <title>Learning OOP Constructor </title> <?php include("class_lib.php"); ?> </head>` <body> <?php // Create object WITHOUT constructor by calling a method $SecurityEngineer = new person(); $SecurityEngineer->set_name("Debbie B"); echo "<br>Debbie's full name: " . $SecurityEngineer->get_name()."<br>"; // Create object WITH a constructor $WanEngineer = new person("Lisa L"); echo "Lisa's full name: " . $WanEngineer->get_name(); ?> </body> </html>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/O3l8L
function name:  (null)
number of ops:  24
compiled vars:  !0 = $SecurityEngineer, !1 = $WanEngineer
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   ECHO                                                     '%3C%21DOCTYPE+html+PUBLIC+%22-%2F%2FW3C%2F%2FDTD+XHTML+1.0+Transitional%2F%2FEN%22+%0A%22http%3A%2F%2Fwww.w3.org%2FTR%2Fxhtml1%2FDTD%2Fxhtml1-transitional.dtd%22%3E%0A%3Chtml+xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%22%3E%0A%3Chead%3E%0A++++%3Cmeta+http-equiv%3D%22Content-Type%22+content%3D%22text%2Fhtml%3B+charset%3DUTF-8%22%3E%3C%2Fmeta%3E%0A++++%3Ctitle%3ELearning+OOP+Constructor+%3C%2Ftitle%3E%0A++++'
   25     1        INCLUDE_OR_EVAL                                          'class_lib.php', INCLUDE
   26     2        ECHO                                                     '%3C%2Fhead%3E%60%0A%0A%3Cbody%3E%0A%0A'
   32     3        NEW                                              $3      'person'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $3
   33     6        INIT_METHOD_CALL                                         !0, 'set_name'
          7        SEND_VAL_EX                                              'Debbie+B'
          8        DO_FCALL                                      0          
   34     9        INIT_METHOD_CALL                                         !0, 'get_name'
         10        DO_FCALL                                      0  $7      
         11        CONCAT                                           ~8      '%3Cbr%3EDebbie%27s+full+name%3A+', $7
         12        CONCAT                                           ~9      ~8, '%3Cbr%3E'
         13        ECHO                                                     ~9
   37    14        NEW                                              $10     'person'
         15        SEND_VAL_EX                                              'Lisa+L'
         16        DO_FCALL                                      0          
         17        ASSIGN                                                   !1, $10
   38    18        INIT_METHOD_CALL                                         !1, 'get_name'
         19        DO_FCALL                                      0  $13     
         20        CONCAT                                           ~14     'Lisa%27s+full+name%3A+', $13
         21        ECHO                                                     ~14
   41    22        ECHO                                                     '%0A%3C%2Fbody%3E%0A%3C%2Fhtml%3E'
   43    23      > RETURN                                                   1

Class person:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/O3l8L
function name:  __construct
number of ops:  4
compiled vars:  !0 = $persons_name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV_INIT                                        !0      null
    6     1        ASSIGN_OBJ                                               'name'
          2        OP_DATA                                                  !0
    7     3      > RETURN                                                   null

End of function __construct

Function set_name:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/O3l8L
function name:  set_name
number of ops:  4
compiled vars:  !0 = $new_name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        ASSIGN_OBJ                                               'name'
          2        OP_DATA                                                  !0
   11     3      > RETURN                                                   null

End of function set_name

Function get_name:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/O3l8L
function name:  get_name
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   FETCH_OBJ_R                                      ~0      'name'
          1      > RETURN                                                   ~0
   15     2*     > RETURN                                                   null

End of function get_name

End of class person.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.09 ms | 944 KiB | 14 Q