3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Update manifest generator for Chrome * * @category [cv-pls] * @package Chrome * @author Chris Wright <info@daverandom.com> */ class ChromeUpdateManifestGenerator { /** * @var string Namespace URL for manifest XML */ private $nsUrl = 'http://www.google.com/update2/response'; /** * Create a new node, append it to the specified parent and add attributes * * @param \DOMNode $parent * @param string $tagName * @param array $attributes * @return \DOMElement */ private function appendNode(\DOMNode $parent, $tagName, array $attributes = []) { $newNode = $parent->ownerDocument->createElementNS($this->nsUrl, $tagName); foreach ($attributes as $name => $value) { $newNode->setAttribute($name, $value); } $parent->appendChild($newNode); } /** * Generate the update manifest document * * @param string $appId * @param string $version * @param string $packageUrl * @return \DOMDocument */ public function generate($appId, $version, $packageUrl) { $document = new \DOMDocument('1.0', 'utf-8'); $document->formatOutput = true; $rootEl = $this->appendNode($document, 'gupdate', ['protocol' => '2.0']); $appEl = $this->appendNode($rootEl, 'app', ['appid' => $appId]); $this->appendNode($appEl, 'updatecheck', ['codebase' => $packageUrl, 'version' => $version]); return $document; } } $obj = new ChromeUpdateManifestGenerator; echo $obj->generate('abcdef', '1.2.3.4', 'http://foo.com/')->saveXML();
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 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: Call to a member function createElementNS() on null in /in/dEqK0:27 Stack trace: #0 /in/dEqK0(49): ChromeUpdateManifestGenerator->appendNode(Object(DOMDocument), 'gupdate', Array) #1 /in/dEqK0(59): ChromeUpdateManifestGenerator->generate('abcdef', '1.2.3.4', 'http://foo.com/') #2 {main} thrown in /in/dEqK0 on line 27
Process exited with code 255.
Output for 5.6.0 - 5.6.28
Fatal error: Call to a member function createElementNS() on null in /in/dEqK0 on line 27
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38
Fatal error: Call to a member function createElementNS() on a non-object in /in/dEqK0 on line 27
Process exited with code 255.
Output for 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/dEqK0 on line 25
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/dEqK0 on line 25 Parse error: syntax error, unexpected '[' in /in/dEqK0 on line 25
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/dEqK0 on line 25 Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in /in/dEqK0 on line 25
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/dEqK0 on line 15
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/dEqK0 on line 15
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/dEqK0 on line 15
Process exited with code 255.

preferences:
250.17 ms | 401 KiB | 397 Q