3v4l.org

run code in 300+ PHP versions simultaneously
<?php function convertHashtags($str) { $regex = '/@([a-zA-Z0-9]+[\sa-zA-Z0-9]*)/'; if(preg_match($regex,$str,$matches) === 1){ list($username,$name) = [$matches[0] , strtolower(str_replace(' ','',$matches[1]))]; return "<a href='profile?id=$name'>$username</a>"; } throw new Exception('Unable to find username in the given string'); } $string = 'I am @Marie Lee, nice to meet you!'; $string = convertHashtags($string); echo $string;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/e2S8C
function name:  (null)
number of ops:  7
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                   !0, 'I+am+%40Marie+Lee%2C+nice+to+meet+you%21'
   12     1        INIT_FCALL                                               'converthashtags'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $2      
          4        ASSIGN                                                   !0, $2
   13     5        ECHO                                                     !0
   14     6      > RETURN                                                   1

Function converthashtags:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 32
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/e2S8C
function name:  convertHashtags
number of ops:  37
compiled vars:  !0 = $str, !1 = $regex, !2 = $matches, !3 = $username, !4 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        ASSIGN                                                   !1, '%2F%40%28%5Ba-zA-Z0-9%5D%2B%5B%5Csa-zA-Z0-9%5D%2A%29%2F'
    4     2        INIT_FCALL                                               'preg_match'
          3        SEND_VAR                                                 !1
          4        SEND_VAR                                                 !0
          5        SEND_REF                                                 !2
          6        DO_ICALL                                         $6      
          7        IS_IDENTICAL                                             $6, 1
          8      > JMPZ                                                     ~7, ->32
    5     9    >   FETCH_DIM_R                                      ~8      !2, 0
         10        INIT_ARRAY                                       ~9      ~8
         11        INIT_FCALL                                               'strtolower'
         12        INIT_FCALL                                               'str_replace'
         13        SEND_VAL                                                 '+'
         14        SEND_VAL                                                 ''
         15        FETCH_DIM_R                                      ~10     !2, 1
         16        SEND_VAL                                                 ~10
         17        DO_ICALL                                         $11     
         18        SEND_VAR                                                 $11
         19        DO_ICALL                                         $12     
         20        ADD_ARRAY_ELEMENT                                ~9      $12
         21        FETCH_LIST_R                                     $13     ~9, 0
         22        ASSIGN                                                   !3, $13
         23        FETCH_LIST_R                                     $15     ~9, 1
         24        ASSIGN                                                   !4, $15
         25        FREE                                                     ~9
    6    26        ROPE_INIT                                     5  ~18     '%3Ca+href%3D%27profile%3Fid%3D'
         27        ROPE_ADD                                      1  ~18     ~18, !4
         28        ROPE_ADD                                      2  ~18     ~18, '%27%3E'
         29        ROPE_ADD                                      3  ~18     ~18, !3
         30        ROPE_END                                      4  ~17     ~18, '%3C%2Fa%3E'
         31      > RETURN                                                   ~17
    8    32    >   NEW                                              $21     'Exception'
         33        SEND_VAL_EX                                              'Unable+to+find+username+in+the+given+string'
         34        DO_FCALL                                      0          
         35      > THROW                                         0          $21
    9    36*     > RETURN                                                   null

End of function converthashtags

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.09 ms | 1007 KiB | 17 Q