3v4l.org

run code in 500+ PHP versions simultaneously
<?php $replacer = 'href="https://example.net"'; $homepage = preg_replace_callback('/<body.*?>(.*)<\/body>/', function($matches) use($replacer) { return preg_replace("/(?<=href=(\"|'))[^\"']+(?=(\"|'))/",$replacer,$matches[0]); },'<body><a class="attribute" href="https://mother.com"/> <a class="attribute" href="https://mothers.com"></a></body>'); echo $homepage;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Fvh9d9
function name:  (null)
number of ops:  11
compiled vars:  !0 = $replacer, !1 = $homepage
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, 'href%3D%22https%3A%2F%2Fexample.net%22'
    5     1        INIT_FCALL                                                   'preg_replace_callback'
          2        SEND_VAL                                                     '%2F%3Cbody.%2A%3F%3E%28.%2A%29%3C%5C%2Fbody%3E%2F'
          3        DECLARE_LAMBDA_FUNCTION                              ~3      [0]
          4        BIND_LEXICAL                                                 ~3, !0
    7     5        SEND_VAL                                                     ~3
          6        SEND_VAL                                                     '%3Cbody%3E%3Ca+class%3D%22attribute%22+href%3D%22https%3A%2F%2Fmother.com%22%2F%3E+%3Ca+class%3D%22attribute%22+href%3D%22https%3A%2F%2Fmothers.com%22%3E%3C%2Fa%3E%3C%2Fbody%3E'
    5     7        DO_ICALL                                             $4      
          8        ASSIGN                                                       !1, $4
    9     9        ECHO                                                         !1
   10    10      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Fvh9d9
function name:  {closure:/in/Fvh9d9:5}
number of ops:  7
compiled vars:  !0 = $matches, !1 = $replacer
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   RECV                                                 !0      
          1        BIND_STATIC                                                  !1
    6     2        FETCH_DIM_R                                          ~2      !0, 0
          3        FRAMELESS_ICALL_3                preg_replace        ~3      '%2F%28%3F%3C%3Dhref%3D%28%22%7C%27%29%29%5B%5E%22%27%5D%2B%28%3F%3D%28%22%7C%27%29%29%2F', !1
          4        OP_DATA                                                      ~2
          5      > RETURN                                                       ~3
    7     6*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
166.07 ms | 1914 KiB | 14 Q