3v4l.org

run code in 300+ PHP versions simultaneously
<?php function txt2link($text){ // force http: on www. $text = preg_replace( "www\.", "http://www.", $text ); // eliminate duplicates after force $text = preg_replace( "http://http://www\.", "http://www.", $text ); $text = preg_replace( "https://http://www\.", "https://www.", $text ); // The Regular Expression filter $reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/"; // Check if there is a url in the text if(preg_match($reg_exUrl, $text, $url)) { // make the urls hyper links $text = preg_replace($reg_exUrl, '<a href="'.$url[0].'" rel="nofollow">'.$url[0].'</a>', $text); } // if no urls in the text just return the text return ($text); } echo txt2link('http://www.snoodo.com');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3l3gB
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   INIT_FCALL                                               'txt2link'
          1        SEND_VAL                                                 'http%3A%2F%2Fwww.snoodo.com'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function txt2link:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 38
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
filename:       /in/3l3gB
function name:  txt2link
number of ops:  40
compiled vars:  !0 = $text, !1 = $reg_exUrl, !2 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'preg_replace'
          2        SEND_VAL                                                 'www%5C.'
          3        SEND_VAL                                                 'http%3A%2F%2Fwww.'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $3      
          6        ASSIGN                                                   !0, $3
    6     7        INIT_FCALL                                               'preg_replace'
          8        SEND_VAL                                                 'http%3A%2F%2Fhttp%3A%2F%2Fwww%5C.'
          9        SEND_VAL                                                 'http%3A%2F%2Fwww.'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $5      
         12        ASSIGN                                                   !0, $5
    7    13        INIT_FCALL                                               'preg_replace'
         14        SEND_VAL                                                 'https%3A%2F%2Fhttp%3A%2F%2Fwww%5C.'
         15        SEND_VAL                                                 'https%3A%2F%2Fwww.'
         16        SEND_VAR                                                 !0
         17        DO_ICALL                                         $7      
         18        ASSIGN                                                   !0, $7
   10    19        ASSIGN                                                   !1, '%2F%28http%7Chttps%7Cftp%7Cftps%29%5C%3A%5C%2F%5C%2F%5Ba-zA-Z0-9%5C-%5C.%5D%2B%5C.%5Ba-zA-Z%5D%7B2%2C3%7D%28%5C%2F%5CS%2A%29%3F%2F'
   12    20        INIT_FCALL                                               'preg_match'
         21        SEND_VAR                                                 !1
         22        SEND_VAR                                                 !0
         23        SEND_REF                                                 !2
         24        DO_ICALL                                         $10     
         25      > JMPZ                                                     $10, ->38
   14    26    >   INIT_FCALL                                               'preg_replace'
         27        SEND_VAR                                                 !1
         28        FETCH_DIM_R                                      ~11     !2, 0
         29        CONCAT                                           ~12     '%3Ca+href%3D%22', ~11
         30        CONCAT                                           ~13     ~12, '%22+rel%3D%22nofollow%22%3E'
         31        FETCH_DIM_R                                      ~14     !2, 0
         32        CONCAT                                           ~15     ~13, ~14
         33        CONCAT                                           ~16     ~15, '%3C%2Fa%3E'
         34        SEND_VAL                                                 ~16
         35        SEND_VAR                                                 !0
         36        DO_ICALL                                         $17     
         37        ASSIGN                                                   !0, $17
   16    38    > > RETURN                                                   !0
   17    39*     > RETURN                                                   null

End of function txt2link

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.22 ms | 1403 KiB | 18 Q