3v4l.org

run code in 300+ PHP versions simultaneously
<?php function replace($url){ $url = str_replace("\\r","\r",$url); $url = str_replace("\\n","\n<BR>",$url); $url = str_replace("\\n\\r","\n\r",$url); $in=array( '`((?:https?|ftp)://\S+[[:alnum:]]/?)`si', '`((?<!//)(www\.\S+[[:alnum:]]/?))`si', '`((?:https?|ftp)://\S+[[:alnum:]]\.(png|jpeg|jpg|gif)\b`si', //'`((?<!//)(www\.\S+[[:alnum:]]\.(png|jpeg|jpg|gif)\b))`si' ); // это для ссылок и фото $out=array( '<a style="color:navy;" href="$1" rel="nofollow">$1</a>', '<a style="color:navy;" href="http://$1" rel=\'nofollow\'>$1</a>', '<img src="$1" rel="nofollow">', //'<img src="http://$1" rel=\'nofollow\'>' ); return preg_replace($in, $out, $url); } echo replace('dfd dfdf http://site.ru/ ddd fff');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aKR6T
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   INIT_FCALL                                               'replace'
          1        SEND_VAL                                                 'dfd+dfdf+http%3A%2F%2Fsite.ru%2F+ddd+fff'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function replace:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aKR6T
function name:  replace
number of ops:  28
compiled vars:  !0 = $url, !1 = $in, !2 = $out
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        INIT_FCALL                                               'str_replace'
          2        SEND_VAL                                                 '%5Cr'
          3        SEND_VAL                                                 '%0D'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $3      
          6        ASSIGN                                                   !0, $3
    4     7        INIT_FCALL                                               'str_replace'
          8        SEND_VAL                                                 '%5Cn'
          9        SEND_VAL                                                 '%0A%3CBR%3E'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $5      
         12        ASSIGN                                                   !0, $5
    5    13        INIT_FCALL                                               'str_replace'
         14        SEND_VAL                                                 '%5Cn%5Cr'
         15        SEND_VAL                                                 '%0A%0D'
         16        SEND_VAR                                                 !0
         17        DO_ICALL                                         $7      
         18        ASSIGN                                                   !0, $7
    7    19        ASSIGN                                                   !1, <array>
   14    20        ASSIGN                                                   !2, <array>
   20    21        INIT_FCALL                                               'preg_replace'
         22        SEND_VAR                                                 !1
         23        SEND_VAR                                                 !2
         24        SEND_VAR                                                 !0
         25        DO_ICALL                                         $11     
         26      > RETURN                                                   $11
   21    27*     > RETURN                                                   null

End of function replace

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.07 ms | 1398 KiB | 18 Q