3v4l.org

run code in 300+ PHP versions simultaneously
<?php function add_href_to_links($string) { $str = $string; $str = preg_replace("/([ \t]|^)www\./i", "\\1http://www.", $str); $str = preg_replace("/([ \t]|^)ftp\./i", "\\1ftp://ftp.", $str); $str = preg_replace("/(http:\/\/[^ )\r\n!]+)/i", "<a href=\"\\1\">\\1</a>", $str); $str = preg_replace("/(https:\/\/[^ )\r\n!]+)/i", "<a href=\"\\1\">\\1</a>", $str); $str = preg_replace("/(ftp:\/\/[^ )\r\n!]+)/i", "<a href=\"\\1\">\\1</a>", $str); $str = preg_replace("/([-a-z0-9_]+(\.[_a-z0-9-]+)*@([a-z0-9-]+(\.[a-z0-9-]+)+))/i", "<a href=\"mailto:\\1\">\\1</a>", $str); $new_string = $str; return $new_string; } $str = 'שלום שלום\nhttps://www.youtube.com/watch?v=2w0JiLKQ3-o\n"asd" ש`מגניב'; $str=strip_tags($str,'<div><br><a><p><b><span>'); $str = str_replace('\r\n','',$str); $str = add_href_to_links($str); echo $str; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2SvWo
function name:  (null)
number of ops:  18
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   ASSIGN                                                   !0, '%D7%A9%D7%9C%D7%95%D7%9D+%D7%A9%D7%9C%D7%95%D7%9D%5Cnhttps%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D2w0JiLKQ3-o%5Cn%22asd%22+%D7%A9%60%D7%9E%D7%92%D7%A0%D7%99%D7%91'
   14     1        INIT_FCALL                                               'strip_tags'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 '%3Cdiv%3E%3Cbr%3E%3Ca%3E%3Cp%3E%3Cb%3E%3Cspan%3E'
          4        DO_ICALL                                         $2      
          5        ASSIGN                                                   !0, $2
   15     6        INIT_FCALL                                               'str_replace'
          7        SEND_VAL                                                 '%5Cr%5Cn'
          8        SEND_VAL                                                 ''
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $4      
         11        ASSIGN                                                   !0, $4
   16    12        INIT_FCALL                                               'add_href_to_links'
         13        SEND_VAR                                                 !0
         14        DO_FCALL                                      0  $6      
         15        ASSIGN                                                   !0, $6
   17    16        ECHO                                                     !0
   18    17      > RETURN                                                   1

Function add_href_to_links:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2SvWo
function name:  add_href_to_links
number of ops:  41
compiled vars:  !0 = $string, !1 = $str, !2 = $new_string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        ASSIGN                                                   !1, !0
    4     2        INIT_FCALL                                               'preg_replace'
          3        SEND_VAL                                                 '%2F%28%5B+%09%5D%7C%5E%29www%5C.%2Fi'
          4        SEND_VAL                                                 '%5C1http%3A%2F%2Fwww.'
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $4      
          7        ASSIGN                                                   !1, $4
    5     8        INIT_FCALL                                               'preg_replace'
          9        SEND_VAL                                                 '%2F%28%5B+%09%5D%7C%5E%29ftp%5C.%2Fi'
         10        SEND_VAL                                                 '%5C1ftp%3A%2F%2Fftp.'
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                         $6      
         13        ASSIGN                                                   !1, $6
    6    14        INIT_FCALL                                               'preg_replace'
         15        SEND_VAL                                                 '%2F%28http%3A%5C%2F%5C%2F%5B%5E+%29%0D%0A%21%5D%2B%29%2Fi'
         16        SEND_VAL                                                 '%3Ca+href%3D%22%5C1%22%3E%5C1%3C%2Fa%3E'
         17        SEND_VAR                                                 !1
         18        DO_ICALL                                         $8      
         19        ASSIGN                                                   !1, $8
    7    20        INIT_FCALL                                               'preg_replace'
         21        SEND_VAL                                                 '%2F%28https%3A%5C%2F%5C%2F%5B%5E+%29%0D%0A%21%5D%2B%29%2Fi'
         22        SEND_VAL                                                 '%3Ca+href%3D%22%5C1%22%3E%5C1%3C%2Fa%3E'
         23        SEND_VAR                                                 !1
         24        DO_ICALL                                         $10     
         25        ASSIGN                                                   !1, $10
    8    26        INIT_FCALL                                               'preg_replace'
         27        SEND_VAL                                                 '%2F%28ftp%3A%5C%2F%5C%2F%5B%5E+%29%0D%0A%21%5D%2B%29%2Fi'
         28        SEND_VAL                                                 '%3Ca+href%3D%22%5C1%22%3E%5C1%3C%2Fa%3E'
         29        SEND_VAR                                                 !1
         30        DO_ICALL                                         $12     
         31        ASSIGN                                                   !1, $12
    9    32        INIT_FCALL                                               'preg_replace'
         33        SEND_VAL                                                 '%2F%28%5B-a-z0-9_%5D%2B%28%5C.%5B_a-z0-9-%5D%2B%29%2A%40%28%5Ba-z0-9-%5D%2B%28%5C.%5Ba-z0-9-%5D%2B%29%2B%29%29%2Fi'
         34        SEND_VAL                                                 '%3Ca+href%3D%22mailto%3A%5C1%22%3E%5C1%3C%2Fa%3E'
         35        SEND_VAR                                                 !1
         36        DO_ICALL                                         $14     
         37        ASSIGN                                                   !1, $14
   10    38        ASSIGN                                                   !2, !1
   11    39      > RETURN                                                   !2
   12    40*     > RETURN                                                   null

End of function add_href_to_links

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.17 ms | 1403 KiB | 20 Q