3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getDescriptionAttribute($string) { $pattern = "~(https?://\S+)|([^\s@]+@[^\s@]+)|(\+\d+)~"; return preg_replace_callback($pattern, function($matches) { $template = '<a href="%1$s%2$s" rel="noopener nofollow" target="_blank">%2$s</a>'; if ($matches[1] !== "") return sprintf($template, "", $matches[1]); if ($matches[2] !== "") return sprintf($template, "mailto:", $matches[2]); if ($matches[3] !== "") return sprintf($template, "tel:", $matches[3]); }, $string); } $str = 'http://google.com tester@gmail.com +1818254545400'; echo getDescriptionAttribute($str);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7e52T
function name:  (null)
number of ops:  6
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   ASSIGN                                                   !0, 'http%3A%2F%2Fgoogle.com%0Atester%40gmail.com%0A%2B1818254545400'
   20     1        INIT_FCALL                                               'getdescriptionattribute'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $2      
          4        ECHO                                                     $2
          5      > RETURN                                                   1

Function getdescriptionattribute:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7e52T
function name:  getDescriptionAttribute
number of ops:  10
compiled vars:  !0 = $string, !1 = $pattern
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, '%7E%28https%3F%3A%2F%2F%5CS%2B%29%7C%28%5B%5E%5Cs%40%5D%2B%40%5B%5E%5Cs%40%5D%2B%29%7C%28%5C%2B%5Cd%2B%29%7E'
    6     2        INIT_FCALL                                               'preg_replace_callback'
          3        SEND_VAR                                                 !1
          4        DECLARE_LAMBDA_FUNCTION                          ~3      [0]
   13     5        SEND_VAL                                                 ~3
          6        SEND_VAR                                                 !0
    6     7        DO_ICALL                                         $4      
   13     8      > RETURN                                                   $4
   14     9*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 22
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 32
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7e52T
function name:  {closure}
number of ops:  33
compiled vars:  !0 = $matches, !1 = $template
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    8     1        ASSIGN                                                   !1, '%3Ca+href%3D%22%251%24s%252%24s%22+rel%3D%22noopener+nofollow%22+target%3D%22_blank%22%3E%252%24s%3C%2Fa%3E'
   10     2        FETCH_DIM_R                                      ~3      !0, 1
          3        IS_NOT_IDENTICAL                                         ~3, ''
          4      > JMPZ                                                     ~4, ->12
          5    >   INIT_FCALL                                               'sprintf'
          6        SEND_VAR                                                 !1
          7        SEND_VAL                                                 ''
          8        FETCH_DIM_R                                      ~5      !0, 1
          9        SEND_VAL                                                 ~5
         10        DO_ICALL                                         $6      
         11      > RETURN                                                   $6
   11    12    >   FETCH_DIM_R                                      ~7      !0, 2
         13        IS_NOT_IDENTICAL                                         ~7, ''
         14      > JMPZ                                                     ~8, ->22
         15    >   INIT_FCALL                                               'sprintf'
         16        SEND_VAR                                                 !1
         17        SEND_VAL                                                 'mailto%3A'
         18        FETCH_DIM_R                                      ~9      !0, 2
         19        SEND_VAL                                                 ~9
         20        DO_ICALL                                         $10     
         21      > RETURN                                                   $10
   12    22    >   FETCH_DIM_R                                      ~11     !0, 3
         23        IS_NOT_IDENTICAL                                         ~11, ''
         24      > JMPZ                                                     ~12, ->32
         25    >   INIT_FCALL                                               'sprintf'
         26        SEND_VAR                                                 !1
         27        SEND_VAL                                                 'tel%3A'
         28        FETCH_DIM_R                                      ~13     !0, 3
         29        SEND_VAL                                                 ~13
         30        DO_ICALL                                         $14     
         31      > RETURN                                                   $14
   13    32    > > RETURN                                                   null

End of Dynamic Function 0

End of function getdescriptionattribute

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.31 ms | 1013 KiB | 16 Q