3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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 ?: $parent)->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.1.0
Fatal error: Uncaught TypeError: Argument 1 passed to ChromeUpdateManifestGenerator::appendNode() must be an instance of DOMNode, null given, called in /in/bCOfZ on line 50 and defined in /in/bCOfZ:25 Stack trace: #0 /in/bCOfZ(50): ChromeUpdateManifestGenerator->appendNode(NULL, 'app', Array) #1 /in/bCOfZ(59): ChromeUpdateManifestGenerator->generate('abcdef', '1.2.3.4', 'http://foo.com/') #2 {main} thrown in /in/bCOfZ on line 25
Process exited with code 255.
Output for 5.4.0 - 5.6.28
Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in /in/bCOfZ on line 27
Process exited with code 255.
Output for 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/bCOfZ on line 25
Process exited with code 255.
Output for 5.2.3 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/bCOfZ on line 25 Parse error: syntax error, unexpected '[' in /in/bCOfZ on line 25
Process exited with code 255.
Output for 5.1.0 - 5.2.2
<br /> <b>Warning</b>: Unexpected character in input: '\' (ASCII=92) state=1 in <b>/in/bCOfZ</b> on line <b>25</b><br /> <br /> <b>Parse error</b>: syntax error, unexpected '[' in <b>/in/bCOfZ</b> on line <b>25</b><br />
Process exited with code 255.
Output for 5.0.0 - 5.0.5
<br /> <b>Warning</b>: Unexpected character in input: '\' (ASCII=92) state=1 in <b>/in/bCOfZ</b> on line <b>25</b><br /> <br /> <b>Parse error</b>: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in <b>/in/bCOfZ</b> on line <b>25</b><br />
Process exited with code 255.
Output for 4.4.2 - 4.4.9
<br /> <b>Parse error</b>: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in <b>/in/bCOfZ</b> on line <b>15</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
<br /> <b>Parse error</b>: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in <b>/in/bCOfZ</b> on line <b>15</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.3.4
<br /> <b>Parse error</b>: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in <b>/in/bCOfZ</b> on line <b>15</b><br />
Process exited with code 255.