3v4l.org

run code in 500+ PHP versions simultaneously
<?php function check_link($link) { if(preg_match('#v=\K[a-z\d-]+|v/\K[^&?"]+|v=\K[^&"]+|youtu\.be/\K[^&"]+#', $link, $r)) { echo $r[0]."\n"; $pattern = '#<a\s?href="(https?://(?:www\.)?[^"]+)">\1</a>#i'; return preg_replace($pattern,'<iframe width="560" height="315" src="https://www.youtube.com/embed/'.$r[0].'" frameborder="0"></iframe>',$link); } } echo check_link('<a href="https://www.youtube.com/watch?v=Z7Oc8QaM5VU">https://www.youtube.com/watch?v=Z7Oc8QaM5VU</a>');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aUaYl
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   INIT_FCALL                                                   'check_link'
          1        SEND_VAL                                                     '%3Ca+href%3D%22https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DZ7Oc8QaM5VU%22%3Ehttps%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DZ7Oc8QaM5VU%3C%2Fa%3E'
          2        DO_FCALL                                          0  $0      
          3        ECHO                                                         $0
          4      > RETURN                                                       1

Function check_link:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 17
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aUaYl
function name:  check_link
number of ops:  18
compiled vars:  !0 = $link, !1 = $r, !2 = $pattern
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    5     1        INIT_FCALL                                                   'preg_match'
          2        SEND_VAL                                                     '%23v%3D%5CK%5Ba-z%5Cd-%5D%2B%7Cv%2F%5CK%5B%5E%26%3F%22%5D%2B%7Cv%3D%5CK%5B%5E%26%22%5D%2B%7Cyoutu%5C.be%2F%5CK%5B%5E%26%22%5D%2B%23'
          3        SEND_VAR                                                     !0
          4        SEND_REF                                                     !1
          5        DO_ICALL                                             $3      
          6      > JMPZ                                                         $3, ->17
    7     7    >   FETCH_DIM_R                                          ~4      !1, 0
          8        CONCAT                                               ~5      ~4, '%0A'
          9        ECHO                                                         ~5
    8    10        ASSIGN                                                       !2, '%23%3Ca%5Cs%3Fhref%3D%22%28https%3F%3A%2F%2F%28%3F%3Awww%5C.%29%3F%5B%5E%22%5D%2B%29%22%3E%5C1%3C%2Fa%3E%23i'
    9    11        FETCH_DIM_R                                          ~7      !1, 0
         12        CONCAT                                               ~8      '%3Ciframe+width%3D%22560%22+height%3D%22315%22+src%3D%22https%3A%2F%2Fwww.youtube.com%2Fembed%2F', ~7
         13        CONCAT                                               ~9      ~8, '%22+frameborder%3D%220%22%3E%3C%2Fiframe%3E'
         14        FRAMELESS_ICALL_3                preg_replace        ~10     !2, ~9
         15        OP_DATA                                                      !0
         16      > RETURN                                                       ~10
   11    17    > > RETURN                                                       null

End of function check_link

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
158.55 ms | 2041 KiB | 15 Q