3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace DOMWorks; use \DOMNode, \DOMDocument; class Node extends DOMNode { // methods... public function foo() { echo "Yay for foo!"; } } class Document extends DOMDocument { public function __construct($version = null, $encoding = null) { $this->registerNodeClass('DOMNode', __NAMESPACE__ . '\Node'); } // methods... } $doc = new Document; $doc->foo();
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught Error: Couldn't fetch DOMWorks\Document in /in/Bjgjm:21 Stack trace: #0 /in/Bjgjm(21): DOMDocument->registerNodeClass('DOMNode', 'DOMWorks\\Node') #1 /in/Bjgjm(27): DOMWorks\Document->__construct() #2 {main} thrown in /in/Bjgjm on line 21
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: DOMDocument::registerNodeClass(): Couldn't fetch DOMWorks\Document in /in/Bjgjm on line 21 Fatal error: Uncaught Error: Call to undefined method DOMWorks\Document::foo() in /in/Bjgjm:28 Stack trace: #0 {main} thrown in /in/Bjgjm on line 28
Process exited with code 255.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.38
Warning: DOMDocument::registerNodeClass(): Couldn't fetch DOMWorks\Document in /in/Bjgjm on line 21 Fatal error: Call to undefined method DOMWorks\Document::foo() in /in/Bjgjm on line 28
Process exited with code 255.

preferences:
264.67 ms | 402 KiB | 372 Q