3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<EOF <html> <head> <link href='http://wendyandgabe.blogspot.com/favicon.ico' rel='icon' type='image/x-icon'/> <link href='http://wendyandgabe.blogspot.com/' rel='canonical'/> <link rel="alternate" type="application/atom+xml" title="O&#39; Happy Day! - Atom" href="http://wendyandgabe.blogspot.com/feeds/posts/default" /> <link rel="alternate" type="application/rss+xml" title="O&#39; Happy Day! - RSS" href="http://wendyandgabe.blogspot.com/feeds/posts/default?alt=rss" /> <link rel="service.post" type="application/atom+xml" title="O&#39; Happy Day! - Atom" href="http://www.blogger.com/feeds/5390468261501503598/posts/default" /> </head> <body> </body> </html> EOF; $xml = new DomDocument; $xml->loadXML($html); //create a xpath instance $xpath = new DomXpath($xml); //query for <sub name="Y"> and use the first found item $link = $xpath->query('//link[@type="application/rss+xml"]')->item(0); var_dump($link->getAttribute('href'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PkH8n
function name:  (null)
number of ops:  25
compiled vars:  !0 = $html, !1 = $xml, !2 = $xpath, !3 = $link
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Chtml%3E%0A++%3Chead%3E++++%0A++++%3Clink+href%3D%27http%3A%2F%2Fwendyandgabe.blogspot.com%2Ffavicon.ico%27+rel%3D%27icon%27+type%3D%27image%2Fx-icon%27%2F%3E%0A++++%3Clink+href%3D%27http%3A%2F%2Fwendyandgabe.blogspot.com%2F%27+rel%3D%27canonical%27%2F%3E%0A++++%3Clink+rel%3D%22alternate%22+type%3D%22application%2Fatom%2Bxml%22+title%3D%22O%26%2339%3B+Happy+Day%21+-+Atom%22+href%3D%22http%3A%2F%2Fwendyandgabe.blogspot.com%2Ffeeds%2Fposts%2Fdefault%22+%2F%3E%0A++++%3Clink+rel%3D%22alternate%22+type%3D%22application%2Frss%2Bxml%22+title%3D%22O%26%2339%3B+Happy+Day%21+-+RSS%22+href%3D%22http%3A%2F%2Fwendyandgabe.blogspot.com%2Ffeeds%2Fposts%2Fdefault%3Falt%3Drss%22+%2F%3E%0A++++%3Clink+rel%3D%22service.post%22+type%3D%22application%2Fatom%2Bxml%22+title%3D%22O%26%2339%3B+Happy+Day%21+-+Atom%22+href%3D%22http%3A%2F%2Fwww.blogger.com%2Ffeeds%2F5390468261501503598%2Fposts%2Fdefault%22+%2F%3E%0A++%3C%2Fhead%3E%0A++%3Cbody%3E%0A++%3C%2Fbody%3E%0A%3C%2Fhtml%3E'
   17     1        NEW                                              $5      'DomDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $5
   18     4        INIT_METHOD_CALL                                         !1, 'loadXML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   21     7        NEW                                              $9      'DomXpath'
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !2, $9
   24    11        INIT_METHOD_CALL                                         !2, 'query'
         12        SEND_VAL_EX                                              '%2F%2Flink%5B%40type%3D%22application%2Frss%2Bxml%22%5D'
         13        DO_FCALL                                      0  $12     
         14        INIT_METHOD_CALL                                         $12, 'item'
         15        SEND_VAL_EX                                              0
         16        DO_FCALL                                      0  $13     
         17        ASSIGN                                                   !3, $13
   27    18        INIT_FCALL                                               'var_dump'
         19        INIT_METHOD_CALL                                         !3, 'getAttribute'
         20        SEND_VAL_EX                                              'href'
         21        DO_FCALL                                      0  $15     
         22        SEND_VAR                                                 $15
         23        DO_ICALL                                                 
         24      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.33 ms | 1388 KiB | 15 Q