|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2017-01-24 11:30 UTC] cmb@php.net
-Package: *General Issues
+Package: DOM XML related
[2018-07-27 12:24 UTC] cmb@php.net
-Status: Open
+Status: Verified
[2018-07-27 12:24 UTC] cmb@php.net
[2021-07-09 12:45 UTC] cmb@php.net
-Type: Bug
+Type: Documentation Problem
[2021-07-09 12:45 UTC] cmb@php.net
[2023-09-22 21:36 UTC] nielsdos@php.net
-Status: Verified
+Status: Closed
-Assigned To:
+Assigned To: nielsdos
[2023-09-22 21:36 UTC] nielsdos@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 18 11:00:01 2025 UTC |
Description: ------------ When a class is registered to a DOMDocument via the registerNodeClass method, the assigned class is used to instance the return object from the DOMDOcument. However, the construct method of that class is not called. Test script: --------------- 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; Expected result: ---------------- output "calling child construct..." //printed from child _construct output "Why, hello there!" //printed from child method sayHello() output "bar" //the value of child property after being assigned in constructor Actual result: -------------- //only the sayHello() method fires; construct doesn't happen Why, hello there;