3v4l.org

run code in 500+ PHP versions simultaneously
<?php class SillyTestClass extends DOMElement{ public $foo=null; public function __construct($name,$value=null,$namespace=null){ echo "calling child construct...."; $this->foo="bar"; parent::__construct($name,$value,$namespace); } public function sayHello(){ echo "Why, hello there!"; } } $doc=new DOMDocument(); $doc->registerNodeClass('DOMElement','SillyTestClass'); $doc->loadHTML("<div><h1>Sample</h1></div>"); //THIS WORKS! CUSTOM CLASS BEING USED $doc->documentElement->firstChild->sayHello(); //THIS IS STILL NULL:( Never set by construct, no message saying construct was called either echo $doc->documentElement->firstChild->foo;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sN59G
function name:  (null)
number of ops:  19
compiled vars:  !0 = $doc
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   15     0  E >   NEW                                                  $1      'DOMDocument'
          1        DO_FCALL                                          0          
          2        ASSIGN                                                       !0, $1
   16     3        INIT_METHOD_CALL                                             !0, 'registerNodeClass'
          4        SEND_VAL_EX                                                  'DOMElement'
          5        SEND_VAL_EX                                                  'SillyTestClass'
          6        DO_FCALL                                          0          
   17     7        INIT_METHOD_CALL                                             !0, 'loadHTML'
          8        SEND_VAL_EX                                                  '%3Cdiv%3E%3Ch1%3ESample%3C%2Fh1%3E%3C%2Fdiv%3E'
          9        DO_FCALL                                          0          
   19    10        FETCH_OBJ_R                                          ~6      !0, 'documentElement'
         11        FETCH_OBJ_R                                          ~7      ~6, 'firstChild'
         12        INIT_METHOD_CALL                                             ~7, 'sayHello'
         13        DO_FCALL                                          0          
   22    14        FETCH_OBJ_R                                          ~9      !0, 'documentElement'
         15        FETCH_OBJ_R                                          ~10     ~9, 'firstChild'
         16        FETCH_OBJ_R                                          ~11     ~10, 'foo'
         17        ECHO                                                         ~11
   23    18      > RETURN                                                       1

Class SillyTestClass:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sN59G
function name:  __construct
number of ops:  12
compiled vars:  !0 = $name, !1 = $value, !2 = $namespace
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   RECV                                                 !0      
          1        RECV_INIT                                            !1      null
          2        RECV_INIT                                            !2      null
    6     3        ECHO                                                         'calling+child+construct....'
    7     4        ASSIGN_OBJ                                                   'foo'
          5        OP_DATA                                                      'bar'
    8     6        INIT_STATIC_METHOD_CALL                                      
          7        SEND_VAR_EX                                                  !0
          8        SEND_VAR_EX                                                  !1
          9        SEND_VAR_EX                                                  !2
         10        DO_FCALL                                          0          
    9    11      > RETURN                                                       null

End of function __construct

Function sayhello:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sN59G
function name:  sayHello
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   ECHO                                                         'Why%2C+hello+there%21'
   12     1      > RETURN                                                       null

End of function sayhello

End of class SillyTestClass.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
227.95 ms | 3326 KiB | 13 Q