3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<EOF <div id="nav"> <ul id="someID"> <li><a href="/poker/?ca=v"> THIS </a></li> </ul> </div> EOF; function extractNodeValue($query, $xPath, $attribute = null) { $node = $xPath->query("//{$query}")->item(0); if (!$node) { return null; } return $attribute ? $node->getAttribute($attribute) : $node->nodeValue; } $document = new DOMDocument(); $document->loadHTML($html); $xPath = new DOMXpath($document); $name = extractNodeValue('/a[@href="/poker/?ca=v"]/text()', $xPath); var_dump($name);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/28AmP
function name:  (null)
number of ops:  20
compiled vars:  !0 = $html, !1 = $document, !2 = $xPath, !3 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cdiv+id%3D%22nav%22%3E%0A++++++++%3Cul+id%3D%22someID%22%3E%0A++++++++++++%3Cli%3E%3Ca+href%3D%22%2Fpoker%2F%3Fca%3Dv%22%3E+THIS+%3C%2Fa%3E%3C%2Fli%3E%0A++++++++%3C%2Ful%3E%0A%3C%2Fdiv%3E'
   20     1        NEW                                              $5      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $5
   21     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   22     7        NEW                                              $9      'DOMXpath'
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !2, $9
   23    11        INIT_FCALL                                               'extractnodevalue'
         12        SEND_VAL                                                 '%2Fa%5B%40href%3D%22%2Fpoker%2F%3Fca%3Dv%22%5D%2Ftext%28%29'
         13        SEND_VAR                                                 !2
         14        DO_FCALL                                      0  $12     
         15        ASSIGN                                                   !3, $12
   24    16        INIT_FCALL                                               'var_dump'
         17        SEND_VAR                                                 !3
         18        DO_ICALL                                                 
         19      > RETURN                                                   1

Function extractnodevalue:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 15
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 21
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/28AmP
function name:  extractNodeValue
number of ops:  25
compiled vars:  !0 = $query, !1 = $xPath, !2 = $attribute, !3 = $node
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      null
   12     3        INIT_METHOD_CALL                                         !1, 'query'
          4        NOP                                                      
          5        FAST_CONCAT                                      ~4      '%2F%2F', !0
          6        SEND_VAL_EX                                              ~4
          7        DO_FCALL                                      0  $5      
          8        INIT_METHOD_CALL                                         $5, 'item'
          9        SEND_VAL_EX                                              0
         10        DO_FCALL                                      0  $6      
         11        ASSIGN                                                   !3, $6
   13    12        BOOL_NOT                                         ~8      !3
         13      > JMPZ                                                     ~8, ->15
   14    14    > > RETURN                                                   null
   17    15    > > JMPZ                                                     !2, ->21
         16    >   INIT_METHOD_CALL                                         !3, 'getAttribute'
         17        SEND_VAR_EX                                              !2
         18        DO_FCALL                                      0  $9      
         19        QM_ASSIGN                                        ~10     $9
         20      > JMP                                                      ->23
         21    >   FETCH_OBJ_R                                      ~11     !3, 'nodeValue'
         22        QM_ASSIGN                                        ~10     ~11
         23    > > RETURN                                                   ~10
   18    24*     > RETURN                                                   null

End of function extractnodevalue

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.97 ms | 1394 KiB | 16 Q