3v4l.org

run code in 300+ 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;
Output for git.master_jit, git.master, rfc.property-hooks
Why, hello there!

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
55.98 ms | 401 KiB | 8 Q