3v4l.org

run code in 500+ PHP versions simultaneously
<?php $data = <<<DATA This is a link <a href="https://stackoverflow.com/">SO</a> and this is <a href="http://test.test">unsubscribe</a> and another and this is <a href="http://test.test">UnSubScribe</a>. DATA; $dom = new DomDocument(); $dom->loadHTML($data); $xpath = new DOMXPath($dom); $query = "//a[contains(translate(., 'UNSUBSCRIBE', 'unsubscribe'),'unsubscribe')]"; $anchors = $xpath->query($query); foreach ($anchors as $a) { echo sprintf("%s: %s" . PHP_EOL, $a->nodeValue, $a->getAttribute("href") ); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 28
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 28
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/X95nt
function name:  (null)
number of ops:  30
compiled vars:  !0 = $data, !1 = $dom, !2 = $xpath, !3 = $query, !4 = $anchors, !5 = $a
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, 'This+is+a+link+%3Ca+href%3D%22https%3A%2F%2Fstackoverflow.com%2F%22%3ESO%3C%2Fa%3E+and+this+is+%3Ca+href%3D%22http%3A%2F%2Ftest.test%22%3Eunsubscribe%3C%2Fa%3E+and+%0Aanother+and+this+is+%3Ca+href%3D%22http%3A%2F%2Ftest.test%22%3EUnSubScribe%3C%2Fa%3E.'
    8     1        NEW                                                  $7      'DomDocument'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !1, $7
    9     4        INIT_METHOD_CALL                                             !1, 'loadHTML'
          5        SEND_VAR_EX                                                  !0
          6        DO_FCALL                                          0          
   10     7        NEW                                                  $11     'DOMXPath'
          8        SEND_VAR_EX                                                  !1
          9        DO_FCALL                                          0          
         10        ASSIGN                                                       !2, $11
   11    11        ASSIGN                                                       !3, '%2F%2Fa%5Bcontains%28translate%28.%2C+%27UNSUBSCRIBE%27%2C+%27unsubscribe%27%29%2C%27unsubscribe%27%29%5D'
   12    12        INIT_METHOD_CALL                                             !2, 'query'
         13        SEND_VAR_EX                                                  !3
         14        DO_FCALL                                          0  $15     
         15        ASSIGN                                                       !4, $15
   14    16      > FE_RESET_R                                           $17     !4, ->28
         17    > > FE_FETCH_R                                                   $17, !5, ->28
   16    18    >   FETCH_OBJ_R                                          ~18     !5, 'nodeValue'
   17    19        INIT_METHOD_CALL                                             !5, 'getAttribute'
         20        SEND_VAL_EX                                                  'href'
         21        DO_FCALL                                          0  $19     
         22        ROPE_INIT                                         4  ~21     ~18
         23        ROPE_ADD                                          1  ~21     ~21, '%3A+'
         24        ROPE_ADD                                          2  ~21     ~21, $19
         25        ROPE_END                                          3  ~20     ~21, '%0A'
         26        ECHO                                                         ~20
   14    27      > JMP                                                          ->17
         28    >   FE_FREE                                                      $17
   19    29      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
220.72 ms | 1861 KiB | 13 Q