3v4l.org

run code in 300+ PHP versions simultaneously
$code = ' <pre class="prettyprint"><?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title> SimpleXML Example</title> </head> <body> <h1> Please go <a href="http://www.ucertify.com">http://www.ucertify.com</a> <br/> </h1> </body> </html> </pre> Which of the following statements will display the HREF attribute on the anchor tag if the SimpleXML object is $sxml? | In the script given in the question, HREF is the attribute of the anchor (<a>) tag. Besides this, anchor tag is inside the <h1> tag and <body> tag. Hence, you will access the HREF tag in the following way: <pre class="prettyprint">$sxml->body->h1->a[\'href\']</pre> Fact What is SimpleXML? SimpleXML is a PHP extension that allows users to easily manipulate/use XML data. Its functions let a user convert XML to an object, which can be processed with property selectors and array iterators. Consider the following XML file, which describes a small collection of books in XML format. It has a root node of store having a direct child, i.e., category, which classifies the books as fiction; category has two children() labelled book; "twilight" by Stephinie Mayer and "The Bikers" by Alex R. Stuart. <pre class="prettyprint"><?xml version="1.0"?> <store> <category id="fiction"> <book> <title>twilight</title> <author>Stephinie Mayer</author> </book> <book> <title>The Bikers</title> <author>Alex R. Stuart</author> </book> </category> </store> </pre> To extract the book title and author, a user will run the following PHP script: <pre class="prettyprint"><?php $store = simplexml_load_file(\'store.xml\'); foreach ($store->category as $category) { printf("Category %s\n", $category[\'id\']); foreach ($category->book as $book) { printf("<br>Title: %s\n", $book->title); printf("<br>Author: %s\n", $book->author); } } ?></pre> '; $matches = null; $content = preg_match('#<pre class="prettyprint">(.*?)</pre>#i', $code, $matches); $matches = $matches[1]; var_dump(preg_replace("#$code#", htmlentities($content), $code));

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
7.3.50.0080.01114.43
7.3.40.0130.00714.43
7.3.30.0090.01414.46
7.3.20.0160.00516.54
7.3.10.0050.01016.41
7.3.00.0130.00816.30
7.2.180.0090.01614.89
7.2.170.0130.01314.84
7.2.160.0150.01214.80
7.2.150.0140.00316.77
7.2.140.0080.00816.85
7.2.130.0170.00016.68
7.2.120.0230.00616.68
7.2.110.0160.01616.51
7.2.100.0160.01116.56
7.2.90.0180.00716.59
7.2.80.0160.01216.43
7.2.70.0190.00316.66
7.2.60.0120.01216.80
7.2.50.0000.01116.78
7.2.40.0040.00916.38
7.2.30.0150.00016.46
7.2.20.0070.01016.58
7.2.10.0150.01216.75
7.2.00.0160.00316.57
7.1.280.0100.00515.65
7.1.270.0130.00515.27
7.1.260.0050.01015.27
7.1.250.0100.01315.35

preferences:
144.44 ms | 1394 KiB | 7 Q